heheng
6 天以前 d8012ee77b6a9e86611aae9074d5925826f4210d
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
package com.gkhy.exam.common.domain;
 
 
import cn.hutool.core.convert.Convert;
import com.gkhy.exam.common.utils.ServletUtils;
 
/**
 * 表格数据处理
 *
 */
public class TableSupport
{
    /**
     * 当前记录起始索引
     */
    public static final String PAGE_NUM = "pageNum";
 
    /**
     * 每页显示记录数
     */
    public static final String PAGE_SIZE = "pageSize";
 
    /**
     * 排序列
     */
    public static final String ORDER_BY_COLUMN = "orderByColumn";
 
    /**
     * 排序的方向 "desc" 或者 "asc".
     */
    public static final String IS_ASC = "isAsc";
 
    /**
     * 分页参数合理化
     */
    public static final String REASONABLE = "reasonable";
 
    /**
     * 封装分页对象
     */
    public static PageDomain getPageDomain()
    {
        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
        Integer pageSize=Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
        if(pageSize>100){
            pageSize=100;
        }
        pageDomain.setPageSize(pageSize);
        pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
        pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
        pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
        return pageDomain;
    }
 
    public static PageDomain buildPageRequest()
    {
        return getPageDomain();
    }
}