Parcourir la source

新增toMap方法

周浩 il y a 9 ans
Parent
commit
2d38571c0b

+ 8 - 0
hsweb-web-core/src/main/java/org/hsweb/web/message/ResponseMessage.java

@@ -110,6 +110,14 @@ public class ResponseMessage implements Serializable {
 
     private transient String callback;
 
+    public Map<String, Object> toMap() {
+        Map<String, Object> map = new HashMap<>();
+        map.put("success", this.success);
+        map.put("data", this.getData());
+        map.put("code", this.getCode());
+        return map;
+    }
+
     public ResponseMessage(boolean success, Object data) {
         this.code = success ? "200" : "500";
         if (data == null)