From f8bd1c406ef31027967c0cfa8c2f5f097ae93ec9 Mon Sep 17 00:00:00 2001 From: fwq <582742538@qq.com> Date: 星期二, 07 十一月 2023 16:19:33 +0800 Subject: [PATCH] 群联系方式配置管理 --- src/main/java/com/hx/resultTool/Result.java | 39 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/hx/resultTool/Result.java b/src/main/java/com/hx/resultTool/Result.java index 4c9e2c5..5c696b0 100644 --- a/src/main/java/com/hx/resultTool/Result.java +++ b/src/main/java/com/hx/resultTool/Result.java @@ -1,6 +1,12 @@ 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; +import java.util.List; /** * 缁熶竴杩斿洖鏍煎紡 @@ -56,10 +62,37 @@ /**鏍¢獙杩斿洖鐮�*/ public Boolean checkCode(){ - if(!ResponseCode.SUCCESS.equals(code)){ - return false; + if(ResponseCode.SUCCESS.equals(code)){ + return true; } - return true; + return false; + } + + /**鏍¢獙杩斿洖鐮侊紝杩涜閿欒鎻愮ず*/ + public void checkTips(){ + if(!ResponseCode.SUCCESS.equals(code)){ + throw new TipsException("璇锋眰澶辫触锛�"+this.code+","+this.msg); + } + } + + /**杩斿洖鏁版嵁杞琂SONObject*/ + public JSONObject getJsonObject(Object data){ + return JSONObject.parseObject(JSON.toJSONString(data)); + } + + /**杩斿洖鏁版嵁杞琂SONArray*/ + 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 <T> List<T> getArray(Object data, Class<T> clazz) { + return JSONArray.parseArray(JSON.toJSONString(data), clazz); } /*******************************************************************************/ -- Gitblit v1.8.0