diff --git a/RollCallServer/src/main/java/cc/aspark/result/PageResult.java b/RollCallServer/src/main/java/cc/aspark/result/PageResult.java new file mode 100644 index 0000000..e179b6a --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/result/PageResult.java @@ -0,0 +1,22 @@ +package cc.aspark.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 封装分页查询结果 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PageResult implements Serializable { + + private long total; //总记录数 + + private List records; //当前页数据集合 + +} diff --git a/RollCallServer/src/main/java/cc/aspark/result/Result.java b/RollCallServer/src/main/java/cc/aspark/result/Result.java new file mode 100644 index 0000000..0e57266 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/result/Result.java @@ -0,0 +1,34 @@ +package cc.aspark.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 后端统一返回结果 + * @param + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Result implements Serializable { + + private Integer code; //编码:1成功,0和其它数字为失败 + private String msg; //错误信息 + private T data; //数据 + + public static Result success() { + return new Result<>(1, "success",null); + } + + public static Result success(T object) { + return new Result<>(1, "success", object); + } + + public static Result error(String msg) { + return new Result(0, msg, null); + } + +} \ No newline at end of file