PageBean.java
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.wondertek.util;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.enums.GlobalCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.ArrayList;
import java.util.List;
/**
* 分页对象
*
* @param <T>
*/
@Data
@ToString
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageBean<T> extends ResultBean {
/**
* 总的页数
*/
private Integer totalPage;
/**
* 总记录数
*/
private Long totalCount;
/**
* 分页数据
*/
private List<T> result;
public PageBean() {}
public PageBean(String code, String msg) {
super(code, msg);
}
/**
*
* @param totalPage 总页数
* @param totalCount 总数
* @param result
*/
public <K> PageBean(Integer totalPage, Long totalCount, List<T> result) {
super(GlobalCodeEnum.SUCCESS.getCode(), GlobalCodeEnum.SUCCESS.getMsg());
this.totalPage = totalPage;
this.totalCount = totalCount;
this.result = result;
}
public static <T> PageBean<T> ok(Integer totalPage, Long totalCount, List<T> result){
return new PageBean<>(totalPage, totalCount, result);
}
public static <T> PageBean<T> empty() {
return new PageBean<>(0, 0L, new ArrayList<>());
}
}