Browse Source

添加简易的方法

yangcong 3 years ago
parent
commit
3087d3270c

+ 7 - 2
fm-common/src/main/java/com/persagy/fm/common/response/CommonResult.java

@@ -1,11 +1,12 @@
 package com.persagy.fm.common.response;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
-import com.persagy.common.enums.ResponseCode;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import static com.persagy.common.enums.ResponseCode.A00000;
+
 /**
  * 服务调用消息结果
  * @author Charlie Yu
@@ -30,7 +31,7 @@ public class CommonResult<T> {
      * 构造方法
      */
     public CommonResult(){
-        this(ResponseCode.A00000.getCode(), ResponseCode.A00000.getDesc());
+        this(A00000.getCode(), A00000.getDesc());
     }
 
     /**
@@ -53,4 +54,8 @@ public class CommonResult<T> {
         this.respMsg = respMsg;
         this.content = content;
     }
+
+    public static <T> CommonResult<T> success(T t) {
+        return  new CommonResult<>(A00000.getCode(), A00000.getDesc(),t);
+    }
 }