refactor(PageResult.java): 分页的总条数调整至data的total属性,数据列表移动至data的list属性。

This commit is contained in:
郝先瑞 2022-03-13 15:24:17 +08:00
parent 2a7351d69f
commit 3815fa7946

View File

@ -17,18 +17,30 @@ public class PageResult<T> implements Serializable {
private String code;
private List<T> data;
private long total;
private Data data;
private String msg;
public static <T> PageResult<T> success(IPage<T> page) {
PageResult<T> result = new PageResult<>();
result.setCode(ResultCode.SUCCESS.getCode());
result.setData(page.getRecords());
result.setTotal(page.getTotal());
Data data = new Data<T>();
data.setList(page.getRecords());
data.setTotal(page.getTotal());
result.setData(data);
result.setMsg(ResultCode.SUCCESS.getMsg());
return result;
}
@lombok.Data
public static class Data<T> {
private List<T> list;
private long total;
}
}