|
@@ -3,6 +3,8 @@ package com.dskj.znzn.transData.common.base;
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
import lombok.Data;
|
|
|
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
@ApiModel(description = "返回结果")
|
|
|
@Data
|
|
|
public class R<T> {
|
|
@@ -10,42 +12,47 @@ public class R<T> {
|
|
|
private int code;
|
|
|
private String message;
|
|
|
private T datas;
|
|
|
+ private long total;
|
|
|
|
|
|
- public R(int code, T datas) {
|
|
|
+ public R(int code, String message, T datas) {
|
|
|
this.code = code;
|
|
|
this.message = message;
|
|
|
this.datas = datas;
|
|
|
}
|
|
|
|
|
|
- public R(int code, String message, T datas) {
|
|
|
+ public R(int code, String message, T datas,long total) {
|
|
|
this.code = code;
|
|
|
this.message = message;
|
|
|
this.datas = datas;
|
|
|
+ this.total = total;
|
|
|
}
|
|
|
|
|
|
public static R ok() {
|
|
|
- return new R(200, "success", null);
|
|
|
+ return ok(200, "success", null);
|
|
|
}
|
|
|
|
|
|
public static <T> R<T> ok(T datas) {
|
|
|
- return new R(200, "success", datas);
|
|
|
+ return ok(200, "success", datas);
|
|
|
}
|
|
|
|
|
|
public static <T> R<T> ok(String message, T datas) {
|
|
|
- return new R(200, message, datas);
|
|
|
+ return ok(200, message, datas);
|
|
|
}
|
|
|
|
|
|
|
|
|
public static <T> R<T> ok(int code, String message, T datas) {
|
|
|
+ if (datas instanceof Collection) {
|
|
|
+ return new R(code, message, datas,((Collection) datas).size());
|
|
|
+ }
|
|
|
return new R(code, message, datas);
|
|
|
}
|
|
|
|
|
|
public static R error() {
|
|
|
- return new R(500, "fail", null);
|
|
|
+ return error(500, "fail");
|
|
|
}
|
|
|
|
|
|
public static R error(String message) {
|
|
|
- return new R(500, message, null);
|
|
|
+ return error(500, message);
|
|
|
}
|
|
|
|
|
|
|