--添加resultPage

This commit is contained in:
xuwenbo
2021-05-05 14:30:28 +08:00
parent 4d71eb3e55
commit 5fd79c05da

View File

@ -54,6 +54,18 @@ public class ApiResult<T> implements Serializable {
@ApiModelProperty(value = "响应消息")
private String msg;
/**
* 总条数
*/
@ApiModelProperty(value = "总条数")
private Integer total;
/**
* 总页数
*/
@ApiModelProperty(value = "总页数")
private Integer totalPage;
/**
* 响应数据
*/
@ -87,6 +99,19 @@ public class ApiResult<T> implements Serializable {
return result(apiCode,null,data);
}
public static <T> ApiResult<T> resultPage(Integer total, Integer totalPage, T data){
return (ApiResult<T>) ApiResult.builder()
.total(total)
.totalPage(totalPage)
.status(200)
.msg(null)
.data(data)
.success(true)
.time(new Date())
.build();
}
public static <T> ApiResult<T> result(ApiCode apiCode, String message, T data){
boolean success = false;
if (apiCode.getCode() == ApiCode.SUCCESS.getCode()){