Skip to content

Commit

Permalink
优化filter
Browse files Browse the repository at this point in the history
  • Loading branch information
henryyan committed Aug 14, 2014
1 parent c9220f8 commit 78d17b2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/java/org/springside/modules/orm/PropertyFilter.java
Expand Up @@ -43,7 +43,8 @@ public enum MatchType {

/** 属性数据类型. */
public enum PropertyType {
S(String.class), I(Integer.class), L(Long.class), F(Float.class), N(Double.class), D(Date.class), B(Boolean.class);
S(String.class), I(Integer.class), L(Long.class), F(Float.class), N(Double.class),
D(Date.class), B(Boolean.class), W(String.class);

private Class<?> clazz;

Expand All @@ -59,6 +60,7 @@ public Class<?> getValue() {
private MatchType matchType = null;
private Object matchValue = null;
private String originValue = null;
private String propertyTypeCode = null;

private Class<?> propertyClass = null;
private String[] propertyNames = null;
Expand All @@ -75,7 +77,7 @@ public PropertyFilter(final String filterName, final String value) {

String firstPart = StringUtils.substringBefore(filterName, "_");
String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
String propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());
this.propertyTypeCode = StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

try {
matchType = Enum.valueOf(MatchType.class, matchTypeCode);
Expand Down Expand Up @@ -137,8 +139,11 @@ public static List<PropertyFilter> buildFromHttpRequest(final HttpServletRequest
e.printStackTrace();
}

String firstPart = StringUtils.substringBefore(filterName, "_");
String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);

//如果value值为空,则忽略此filter.
if (StringUtils.isNotBlank(value)) {
if (matchTypeCode.equals("IN") || StringUtils.isNotBlank(value)) {
PropertyFilter filter = new PropertyFilter(filterName, value);
filterList.add(filter);
}
Expand Down Expand Up @@ -234,4 +239,11 @@ public void setPropertyNames(String[] propertyNames) {
this.propertyNames = propertyNames;
}

public String getPropertyTypeCode() {
return propertyTypeCode;
}

public void setPropertyTypeCode(String propertyTypeCode) {
this.propertyTypeCode = propertyTypeCode;
}
}

0 comments on commit 78d17b2

Please sign in to comment.