Skip to content

Commit c486712

Browse files
committed
add filter
1 parent 220e342 commit c486712

File tree

1 file changed

+25
-2
lines changed
  • springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request

1 file changed

+25
-2
lines changed

springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/request/PageRequest.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public PageRequest(int current, int pageSize, Sort sort) {
3939
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
4040
this.servletRequest = attributes.getRequest();
4141
this.syncParameter();
42-
}catch (Exception e){}
42+
} catch (Exception e) {
43+
}
4344
}
4445

4546

@@ -48,7 +49,7 @@ private void syncParameter() {
4849
while (enumeration.hasMoreElements()) {
4950
String key = enumeration.nextElement();
5051
String value = servletRequest.getParameter(key);
51-
if(StringUtils.hasText(value)) {
52+
if (StringUtils.hasText(value)) {
5253
this.filters.put(key, value);
5354
}
5455
}
@@ -80,6 +81,28 @@ public int getIntParameter(String key, int defaultValue) {
8081
return result == null ? defaultValue : Integer.parseInt(result);
8182
}
8283

84+
public Map<String, Object> getFilters() {
85+
return filters;
86+
}
87+
88+
public String getStringFilter(String key) {
89+
return (String) filters.get(key);
90+
}
91+
92+
public String getStringFilter(String key, String defaultValue) {
93+
String result = (String) filters.get(key);
94+
return result == null ? defaultValue : result;
95+
}
96+
97+
public int getIntFilter(String key) {
98+
return Integer.parseInt((String) filters.get(key));
99+
}
100+
101+
public int getIntFilter(String key, int defaultValue) {
102+
String result = (String) filters.get(key);
103+
return result == null ? defaultValue : Integer.parseInt(result);
104+
}
105+
83106

84107
@Override
85108
public int getPageSize() {

0 commit comments

Comments
 (0)