-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaperUtil.java
114 lines (90 loc) · 1.84 KB
/
PaperUtil.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
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
105
106
107
108
109
110
111
112
113
114
package com.nkl.common.util;
import com.nkl.common.domain.BaseDomain;
public class PaperUtil {
/**
* 缺省页行数.
*/
private static final int DEFAULT_PAGE_LIMIT = 12;
/**
* 起始行号.
*/
private int start = 0;
/**
* 页码.
*/
private int pageNo = 1;
/**
* 行数.
*/
private int limit = DEFAULT_PAGE_LIMIT;
/**
* 返回总行数.
*/
private int totalCount = 0;
/**
* 排序字段(例sp.spCode).
*/
private String sort;
/**
* 正序|反序(例ASC).
*/
private String dir;
/**
* 设置分页属性.
*
* @param domain
* 输入DO对象
*/
public void setPagination(BaseDomain domain) {
// 设置分页属性: start,limit,sort,order
domain.setStart((getPageNo() - 1) * getLimit());
domain.setLimit(getLimit());
domain.setSort(getSort());
domain.setOrder(getDir());
}
public int getPageCount() {
if (limit!=0) {
return (totalCount+limit-1)/limit;
}
return totalCount;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
if (this.pageNo <= 0) {
this.pageNo = 1;
}
}
public int getStart() {
return start;
}
public int getPageNo() {
return pageNo;
}
public int getLimit() {
return limit;
}
public int getTotalCount() {
return totalCount;
}
public String getSort() {
return sort;
}
public String getDir() {
return dir;
}
public void setStart(int start) {
this.start = start;
}
public void setLimit(int limit) {
this.limit = limit;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public void setSort(String sort) {
this.sort = sort;
}
public void setDir(String dir) {
this.dir = dir;
}
}