feat: 增加统一响应结果类

backend/dev
Spark 2 months ago
parent cd76a52332
commit acc06c1ab5

@ -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<T> implements Serializable {
private long total; //总记录数
private List<T> records; //当前页数据集合
}

@ -0,0 +1,34 @@
package cc.aspark.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
*
* @param <T>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {
private Integer code; //编码1成功0和其它数字为失败
private String msg; //错误信息
private T data; //数据
public static <T> Result<T> success() {
return new Result<>(1, "success",null);
}
public static <T> Result<T> success(T object) {
return new Result<>(1, "success", object);
}
public static <T> Result<T> error(String msg) {
return new Result(0, msg, null);
}
}
Loading…
Cancel
Save