提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.common.utils; |
H |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
4 |
|
|
5 |
import java.io.Serializable; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
/** |
|
9 |
* 分页工具类 |
|
10 |
* |
|
11 |
* @author Mark sunlightcs@gmail.com |
|
12 |
*/ |
|
13 |
public class PageUtils implements Serializable { |
|
14 |
private static final long serialVersionUID = 1L; |
|
15 |
|
|
16 |
/** |
|
17 |
* 总记录数 |
|
18 |
*/ |
|
19 |
private int total; |
|
20 |
|
|
21 |
/** |
|
22 |
* 总记录数 |
|
23 |
*/ |
|
24 |
private int totalCount; |
|
25 |
/** |
|
26 |
* 每页记录数 |
|
27 |
*/ |
|
28 |
private int pageSize; |
|
29 |
/** |
|
30 |
* 总页数 |
|
31 |
*/ |
|
32 |
private int totalPage; |
|
33 |
/** |
|
34 |
* 当前页数 |
|
35 |
*/ |
|
36 |
private int currPage; |
|
37 |
/** |
|
38 |
* 列表数据 |
|
39 |
*/ |
|
40 |
private List<?> list; |
|
41 |
|
|
42 |
/** |
|
43 |
* 分页 |
|
44 |
* @param list 列表数据 |
|
45 |
* @param totalCount 总记录数 |
|
46 |
* @param pageSize 每页记录数 |
|
47 |
* @param currPage 当前页数 |
|
48 |
*/ |
|
49 |
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) { |
|
50 |
this.list = list; |
|
51 |
this.total = totalCount; |
|
52 |
this.totalCount = totalCount; |
|
53 |
this.pageSize = pageSize; |
|
54 |
this.currPage = currPage; |
|
55 |
this.totalPage = (int)Math.ceil((double)totalCount/pageSize); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* 分页 |
|
60 |
*/ |
|
61 |
public PageUtils(IPage<?> page) { |
|
62 |
this.list = page.getRecords(); |
|
63 |
this.total = (int)page.getTotal(); |
|
64 |
this.totalCount = (int)page.getTotal(); |
|
65 |
this.pageSize = (int)page.getSize(); |
|
66 |
this.currPage = (int)page.getCurrent(); |
|
67 |
this.totalPage = (int)page.getPages(); |
|
68 |
} |
|
69 |
|
|
70 |
public int getTotal() { |
|
71 |
return total; |
|
72 |
} |
|
73 |
|
|
74 |
public void setTotal(int total) { |
|
75 |
this.total = total; |
|
76 |
} |
|
77 |
public int getTotalCount() { |
|
78 |
return totalCount; |
|
79 |
} |
|
80 |
|
|
81 |
public void setTotalCount(int totalCount) { |
|
82 |
this.totalCount = totalCount; |
|
83 |
} |
|
84 |
|
|
85 |
public int getPageSize() { |
|
86 |
return pageSize; |
|
87 |
} |
|
88 |
|
|
89 |
public void setPageSize(int pageSize) { |
|
90 |
this.pageSize = pageSize; |
|
91 |
} |
|
92 |
|
|
93 |
public int getTotalPage() { |
|
94 |
return totalPage; |
|
95 |
} |
|
96 |
|
|
97 |
public void setTotalPage(int totalPage) { |
|
98 |
this.totalPage = totalPage; |
|
99 |
} |
|
100 |
|
|
101 |
public int getCurrPage() { |
|
102 |
return currPage; |
|
103 |
} |
|
104 |
|
|
105 |
public void setCurrPage(int currPage) { |
|
106 |
this.currPage = currPage; |
|
107 |
} |
|
108 |
|
|
109 |
public List<?> getList() { |
|
110 |
return list; |
|
111 |
} |
|
112 |
|
|
113 |
public void setList(List<?> list) { |
|
114 |
this.list = list; |
|
115 |
} |
|
116 |
|
|
117 |
} |