shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.db.page;
 
import com.walker.db.Sorts;
import com.walker.infrastructure.utils.StringUtils;
 
/**
 * 前端分页搜索条件对象使用。
 * @author 时克英
 * @date 2022-11-16
 */
public class PageSearch {
 
    /**
     * 当前记录起始索引
     */
    @Deprecated
//    public static final String PAGE_NUM = "pageIndex";
    public static final String PAGE_NUM = "pageNum";
 
    /**
     * 每页显示记录数
     */
    @Deprecated
    public static final String PAGE_SIZE = "pageSize";
 
    /**
     * 使用新前端的分页参数定义,电商。
     * @date 2023-05-18
     */
    public static final String KEY_PAGE = "page";
    public static final String KEY_PAGE_LIMIT = "limit";
 
    /**
     * 排序列
     */
    @Deprecated
    public static final String ORDER_BY_COLUMN = "orderByColumn";
 
    /**
     * 排序的方向 "desc" 或者 "asc".
     */
    public static final String IS_ASC = "isAsc";
 
    private int pageIndex = 1;
 
    private int pageSize = 20;
 
    /** 排序列 */
    private String orderByColumn;
 
//    /** 分页参数合理化,配合若依前端, 2022-11-16 */
//    private Boolean reasonable = true;
 
    private String orderAsc = Sorts.NAME_ASC;
 
    public int getPageIndex() {
        return pageIndex;
    }
 
    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
 
    public int getPageSize() {
        return pageSize;
    }
 
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
 
    public String getOrderByColumn() {
        return orderByColumn;
    }
 
    public void setOrderByColumn(String orderByColumn) {
        this.orderByColumn = orderByColumn;
    }
 
//    public Boolean getReasonable() {
//        return reasonable;
//    }
//    public void setReasonable(Boolean reasonable) {
//        this.reasonable = reasonable;
//    }
 
    public String getOrderAsc() {
        return orderAsc;
    }
 
    @Deprecated
    public void setOrderAsc(String orderAsc) {
        if (StringUtils.isNotEmpty(orderAsc)) {
            // 兼容前端排序类型
            if ("ascending".equals(orderAsc)) {
                this.orderAsc = Sorts.NAME_ASC;
            }
            else if ("descending".equals(orderAsc)) {
                this.orderAsc = "desc";
            }
            this.orderAsc = orderAsc;
        }
    }
 
    public String getOrderBy() {
        if (StringUtils.isEmpty(orderByColumn)) {
            return StringUtils.EMPTY_STRING;
        }
        return StringUtils.toUnderScoreCase(orderByColumn) + " " + this.orderAsc;
    }
 
}