Browse Source

行情参数更改

ouyang 3 years ago
parent
commit
0ac5a6fd52

+ 75 - 0
src/main/java/com/izouma/nineth/domain/Result.java

@@ -0,0 +1,75 @@
+package com.izouma.nineth.domain;
+
+import com.izouma.nineth.enums.SystemCode;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
+
+import java.util.List;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Result<T> {
+    //返回码
+    private String code;
+    //提示信息
+    private String msg;
+    // 返回对象
+    private List<T> data;
+
+
+    public static Result OK() {
+        return new Result(SystemCode.SUCCESS);
+    }
+
+
+    public static Result error(String code, String msg) {
+        return new Result(code, msg);
+    }
+
+
+    public void setMsgIsNUll(String msg) {
+        if (StringUtils.isBlank(getMsg())) {
+            setMsg(msg);
+        }
+    }
+
+
+    public void setCodeIsNUll(String code) {
+        if (StringUtils.isBlank(getCode())) {
+            setMsg(code);
+        }
+    }
+
+
+    public void setSysCodeIsNUll(SystemCode sysCode) {
+        if (StringUtils.isBlank(getCode())) {
+            setCode(sysCode.getCode());
+        }
+        if (StringUtils.isBlank(getMsg())) {
+            setMsg(sysCode.getMsg());
+        }
+    }
+
+    public Result(SystemCode sysCode) {
+        this.code = sysCode.getCode();
+        this.msg = sysCode.getMsg();
+    }
+
+
+    public Result(String code, String msg) {
+        this(code, msg, null);
+    }
+
+    public void setSystemCode(SystemCode sysCode) {
+        this.code = sysCode.getCode();
+        this.msg = sysCode.getMsg();
+    }
+
+    public  Result<T> success(List<T> data){
+        return new Result<>(SystemCode.SUCCESS.getCode(), SystemCode.SUCCESS.getMsg(),data);
+    }
+}

+ 38 - 0
src/main/java/com/izouma/nineth/enums/SystemCode.java

@@ -0,0 +1,38 @@
+package com.izouma.nineth.enums;
+
+
+public enum SystemCode {
+
+    /**
+     * 操作成功
+     **/
+    SUCCESS("1", "操作成功"),
+    /**
+     * 操作失败
+     **/
+    ERROR("2", "操作失败"),
+    ;
+
+    /**
+     * 自定义状态码
+     **/
+    private String code;
+    /**
+     * 自定义描述
+     **/
+    private String message;
+
+    SystemCode(String code, String message) {
+        this.code = code;
+        this.message = message;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getMsg() {
+        return message;
+    }
+}
+

+ 6 - 0
src/main/java/com/izouma/nineth/web/PriceListController.java

@@ -1,6 +1,7 @@
 package com.izouma.nineth.web;
 
 import com.izouma.nineth.domain.PriceList;
+import com.izouma.nineth.domain.Result;
 import com.izouma.nineth.repo.CollectionRepo;
 import com.izouma.nineth.service.PriceListService;
 import com.izouma.nineth.dto.PageQuery;
@@ -87,5 +88,10 @@ public class PriceListController extends BaseController {
             return map;
         }).collect(Collectors.toList());
     }
+    @GetMapping("/list2")
+//    @Cacheable("priceList")
+    public Result<PriceList> priceList() {
+        return Result.OK().success(priceListRepo.findAll());
+    }
 }