MCPcopy Create free account
hub / github.com/LisenCoding/cangku / PageUtils

Class PageUtils

boot/src/main/java/com/utils/PageUtils.java:13–101  ·  view source on GitHub ↗

分页工具类

Source from the content-addressed store, hash-verified

11 * 分页工具类
12 */
13public class PageUtils implements Serializable {
14 private static final long serialVersionUID = 1L;
15 //总记录数
16 private long total;
17 //每页记录数
18 private int pageSize;
19 //总页数
20 private long totalPage;
21 //当前页数
22 private int currPage;
23 //列表数据
24 private List<?> list;
25
26 /**
27 * 分页
28 * @param list 列表数据
29 * @param totalCount 总记录数
30 * @param pageSize 每页记录数
31 * @param currPage 当前页数
32 */
33 public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
34 this.list = list;
35 this.total = totalCount;
36 this.pageSize = pageSize;
37 this.currPage = currPage;
38 this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
39 }
40
41 /**
42 * 分页
43 */
44 public PageUtils(Page<?> page) {
45 this.list = page.getRecords();
46 this.total = page.getTotal();
47 this.pageSize = page.getSize();
48 this.currPage = page.getCurrent();
49 this.totalPage = page.getPages();
50 }
51
52 /*
53 * 空数据的分页
54 */
55 public PageUtils(Map<String, Object> params) {
56 Page page =new Query(params).getPage();
57 new PageUtils(page);
58 }
59
60
61 public int getPageSize() {
62 return pageSize;
63 }
64
65 public void setPageSize(int pageSize) {
66 this.pageSize = pageSize;
67 }
68
69 public int getCurrPage() {
70 return currPage;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected