-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPage.java
59 lines (53 loc) · 1.08 KB
/
Page.java
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
package com.atguigu.util;
import java.util.List;
public class Page<T> {
/**
* 当前页
*/
@Getter
private Integer pageNo;
/**
* 一页多少条
*/
@Getter
@Setter
private Integer pageSize;
/**
* 数据
*/
@Getter
@Setter
private List<T> data;
/**
* 总条数
*/
@Getter
private Integer totalSize;
/**
* 总页数
*/
@Getter
private Integer totalNo;
public Page(Integer pageNo, Integer pageSize) {
if (pageNo <= 0) {
this.pageNo = 1;
} else {
this.pageNo = pageNo;
}
if (pageSize <= 0) {
this.pageSize = 1;
} else {
this.pageSize = pageSize;
}
}
public void setTotalSize(Integer totalSize) {
this.totalSize = totalSize;
this.totalNo = (totalSize % pageSize) == 0 ? (totalSize / pageSize) : (totalSize / pageSize + 1);
}
/**
* 获取开始索引
*/
public Integer getStartIndex() {
return (this.pageNo - 1) * pageSize;
}
}