|
@@ -21,51 +21,53 @@ package org.hswebframework.web.commons.entity;
|
|
|
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
+import lombok.Getter;
|
|
|
+import lombok.Setter;
|
|
|
+import org.hswebframework.web.commons.entity.param.QueryParamEntity;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@ApiModel(description = "分页结果")
|
|
|
+@Getter
|
|
|
+@Setter
|
|
|
public class PagerResult<E> implements Entity {
|
|
|
private static final long serialVersionUID = -6171751136953308027L;
|
|
|
|
|
|
- public static <E> PagerResult<E> empty(){
|
|
|
+ public static <E> PagerResult<E> empty() {
|
|
|
return new PagerResult<>(0, new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
- public static <E> PagerResult<E> of(int total,List<E> list){
|
|
|
- return new PagerResult<>(total,list);
|
|
|
+ public static <E> PagerResult<E> of(int total, List<E> list) {
|
|
|
+ return new PagerResult<>(total, list);
|
|
|
}
|
|
|
- private int total;
|
|
|
-
|
|
|
- private List<E> data;
|
|
|
|
|
|
- public PagerResult() {
|
|
|
+ public static <E> PagerResult<E> of(int total, List<E> list, QueryParamEntity entity) {
|
|
|
+ PagerResult pagerResult = new PagerResult<>(total, list);
|
|
|
+ pagerResult.setPageIndex(entity.getThinkPageIndex());
|
|
|
+ pagerResult.setPageSize(entity.getPageSize());
|
|
|
+ return pagerResult;
|
|
|
}
|
|
|
|
|
|
- public PagerResult(int total, List<E> data) {
|
|
|
- this.total = total;
|
|
|
- this.data = data;
|
|
|
- }
|
|
|
|
|
|
- @ApiModelProperty("数据总数量")
|
|
|
- public int getTotal() {
|
|
|
- return total;
|
|
|
- }
|
|
|
+ @ApiModelProperty("当前页码")
|
|
|
+ private int pageIndex;
|
|
|
|
|
|
- public PagerResult<E> setTotal(int total) {
|
|
|
- this.total = total;
|
|
|
- return this;
|
|
|
- }
|
|
|
+ @ApiModelProperty("每页数据数量")
|
|
|
+ private int pageSize;
|
|
|
+
|
|
|
+ @ApiModelProperty("数据总数量")
|
|
|
+ private int total;
|
|
|
|
|
|
@ApiModelProperty("查询结果")
|
|
|
- public List<E> getData() {
|
|
|
- return data;
|
|
|
+ private List<E> data;
|
|
|
+
|
|
|
+ public PagerResult() {
|
|
|
}
|
|
|
|
|
|
- public PagerResult<E> setData(List<E> data) {
|
|
|
+ public PagerResult(int total, List<E> data) {
|
|
|
+ this.total = total;
|
|
|
this.data = data;
|
|
|
- return this;
|
|
|
}
|
|
|
|
|
|
}
|