| | |
| | | package com.hx.resultTool; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hx.exception.TipsException; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | |
| | | return false; |
| | | } |
| | | |
| | | /**校验返回码,进行错误提示*/ |
| | | public void checkTips(){ |
| | | if(!ResponseCode.SUCCESS.equals(code)){ |
| | | throw new TipsException("请求失败:"+this.code+","+this.msg); |
| | | } |
| | | } |
| | | |
| | | /**返回数据转JSONObject*/ |
| | | public JSONObject getJsonObject(Object data){ |
| | | return JSONObject.parseObject(JSON.toJSONString(data)); |
| | | } |
| | | |
| | | /**返回数据转JSONArray*/ |
| | | public JSONArray getJsonArray(Object data){ |
| | | return JSONArray.parseArray(JSON.toJSONString(data)); |
| | | } |
| | | |
| | | public <T> T getObject(Object data, Class<T> clazz) { |
| | | return JSONObject.parseObject(JSON.toJSONString(data), clazz); |
| | | } |
| | | |
| | | /*******************************************************************************/ |
| | | |
| | | public String getCode() { |