lihang
2023-04-25 3fade6d3b27f5666672bb3af610020367f790bda
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package com.vci.ubcs.starter.web.pagemodel;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
//package com.vci.starter.web.pagemodel;
 
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
 
public class BaseQueryObject implements Serializable {
    @JSONField(
        serialize = false,
        deserialize = false
    )
    private static final long serialVersionUID = 5608634730007623041L;
    @JSONField
    private Map<String, String> conditionMap = new HashMap();
    @JSONField
    private int page = 1;
    @JSONField
    private String sort;
    @JSONField
    private String order;
    @JSONField
    private int limit = 25;
 
    public BaseQueryObject() {
    }
 
    public BaseQueryObject(Map<String, String> conditionMap) {
        this.setConditionMap(conditionMap);
    }
 
    public BaseQueryObject(int limit) {
        this.setLimit(limit);
    }
 
    public BaseQueryObject(Map<String, String> conditionMap, int limit) {
        this.setConditionMap(conditionMap);
        this.setLimit(limit);
    }
 
    public Map<String, String> getConditionMap() {
        return this.conditionMap;
    }
 
    public Map<String, String> getConditionMapByNick(String nick) {
        if (this.conditionMap != null) {
            Map<String, String> conditionMapHasNick = new HashMap();
            this.conditionMap.forEach((k, v) -> {
                if (!k.contains(".")) {
                    conditionMapHasNick.put(nick + "." + k, v);
                } else {
                    conditionMapHasNick.put(k, v);
                }
 
            });
            return conditionMapHasNick;
        } else {
            return null;
        }
    }
 
    public void setConditionMap(Map<String, String> conditionMap) {
        this.conditionMap = conditionMap;
    }
 
    public int getPage() {
        return this.page;
    }
 
    public void setPage(int page) {
        this.page = page;
    }
 
    public String getSort() {
        return this.sort;
    }
 
    public void setSort(String sort) {
        this.sort = sort;
    }
 
    public String getOrder() {
        return this.order;
    }
 
    public void setOrder(String order) {
        this.order = order;
    }
 
    public int getLimit() {
        return this.limit;
    }
 
    public void setLimit(int limit) {
        this.limit = limit;
    }
 
    @JSONField(
        serialize = false,
        deserialize = false
    )
    public PageHelper getPageHelper() {
        PageHelper pageHelper = new PageHelper(this.limit);
        pageHelper.setPage(this.getPage());
        pageHelper.setSort(this.getSort());
        pageHelper.setOrder(this.getOrder());
        return pageHelper;
    }
 
    public BaseQueryObject addSort(String sort, String order) {
        this.setSort(StringUtils.isBlank(this.getSort()) ? sort : this.getSort() + "," + sort);
        this.setOrder(StringUtils.isBlank(this.getOrder()) ? order : this.getOrder() + "," + order);
        return this;
    }
 
    public BaseQueryObject addCondition(String key, String value) {
        if (this.getConditionMap() == null) {
            this.conditionMap = new HashMap();
        }
 
        this.conditionMap.put(key, value);
        return this;
    }
 
    public BaseQueryObject page(PageHelper pageHelper) {
        this.setSort(pageHelper.getSort());
        this.setOrder(pageHelper.getOrder());
        this.setPage(pageHelper.getPage());
        this.setLimit(pageHelper.getLimit());
        return this;
    }
 
    @JSONField(
        serialize = false,
        deserialize = false
    )
    public Map<String, String> getFeignRequestMap() {
        Map<String, String> feignRequestMap = new HashMap();
        if (this.conditionMap != null) {
            this.getConditionMap().forEach((k, v) -> {
                feignRequestMap.put("conditionMap[\"" + k + "\"]", v);
            });
        }
 
        feignRequestMap.put("page", this.getPage() + "");
        feignRequestMap.put("limit", this.getLimit() + "");
        feignRequestMap.put("sort", this.getSort());
        feignRequestMap.put("order", this.getOrder());
        return feignRequestMap;
    }
 
    @Override
    public String toString() {
        return "BaseQueryObject{conditionMap=" + this.conditionMap + ", page=" + this.page + ", sort='" + this.sort + '\'' + ", order='" + this.order + '\'' + ", limit=" + this.limit + '}';
    }
 
}