PageTemplate.java
1.99 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.diligrp.website.util.web;
import java.util.List;
import com.diligrp.website.util.dao.BaseQuery;
public class PageTemplate {
public static PageTemplate create(BaseQuery bq, int totalSize, List<?> list) {
PageTemplate template = new PageTemplate();
template.setTotalSize(totalSize);
template.setList(list);
template.setPageSize(bq.getPageSize());
template.setCurrPage(bq.getCurrPage());
template.setQuery(bq);
return template;
}
private BaseQuery query;
/**
* 总页数
*/
private int totalPage;
/**
* 总数量
*/
private int totalSize;
/**
* 当前页
*/
private int currPage;
/**
* 每页数量
*/
private int pageSize;
/**
* 数据集合
*/
private List<?> list;
public int getTotalPage() {
totalPage = totalSize / pageSize + (totalSize % pageSize > 0 ? 1 : 0);
if (totalPage == 0) {
totalPage = 1;
}
return totalPage;
}
public int getTotalSize() {
return totalSize;
}
public void setTotalSize(int totalSize) {
this.totalSize = totalSize;
}
public int getCurrPage() {
return currPage;
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
@Override
public String toString() {
return "PageTemplate [totalPage=" + totalPage + ", totalSize="
+ totalSize + ", currPage=" + currPage + ", pageSize="
+ pageSize + ", list=" + list + "]";
}
public BaseQuery getQuery() {
return query;
}
public void setQuery(BaseQuery query) {
this.query = query;
}
}