From 32e62c64b2e384d11443cb4ae90177d5664dc8d8 Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期五, 17 六月 2022 18:53:31 +0800
Subject: [PATCH] Object返回Json

---
 src/main/java/com/hx/resultTool/Result.java |   28 +++++++++++++++++++++++++---
 1 files changed, 25 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..698438a 100644
--- a/src/main/java/com/hx/resultTool/Result.java
+++ b/src/main/java/com/hx/resultTool/Result.java
@@ -1,5 +1,10 @@
 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;
 
 /**
@@ -56,10 +61,27 @@
 
     /**鏍¢獙杩斿洖鐮�*/
     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));
     }
 
     /*******************************************************************************/

--
Gitblit v1.8.0