提交 e6267412 编写于 作者: O o2null

Merge branch 'feature/增加视图数组查询条件' into 'wrdp'

[数据中心]增加视图数组类型查询条件:in

See merge request o2oa/o2oa!1991
...@@ -12,6 +12,7 @@ public abstract class Comparison { ...@@ -12,6 +12,7 @@ public abstract class Comparison {
private static String[] like = new String[] { "like" }; private static String[] like = new String[] { "like" };
private static String[] notLike = new String[] { "notLike", "not like" }; private static String[] notLike = new String[] { "notLike", "not like" };
private static String[] between = new String[] { "range", "between" }; private static String[] between = new String[] { "range", "between" };
private static String[] isMember = new String[] { "isMember", "in" };
public static boolean isEquals(String comparison) throws Exception { public static boolean isEquals(String comparison) throws Exception {
for (String str : equals) { for (String str : equals) {
...@@ -94,6 +95,15 @@ public abstract class Comparison { ...@@ -94,6 +95,15 @@ public abstract class Comparison {
return false; return false;
} }
public static boolean isIsMember(String comparison) throws Exception {
for (String str : isMember) {
if (StringUtils.equalsIgnoreCase(str, StringUtils.trim(comparison))) {
return true;
}
}
return false;
}
public static String getMatchCom(String comparison) throws Exception { public static String getMatchCom(String comparison) throws Exception {
if(isNotEquals(comparison)){ if(isNotEquals(comparison)){
return notEquals[notEquals.length-1]; return notEquals[notEquals.length-1];
...@@ -116,6 +126,9 @@ public abstract class Comparison { ...@@ -116,6 +126,9 @@ public abstract class Comparison {
}else if(isNotLike(comparison)){ }else if(isNotLike(comparison)){
return notLike[notLike.length-1]; return notLike[notLike.length-1];
}else if(isIsMember(comparison)){
return isMember[isMember.length-1];
}else{ }else{
return equals[equals.length-1]; return equals[equals.length-1];
} }
......
package com.x.query.core.express.plan; package com.x.query.core.express.plan;
import java.util.Date; import java.util.*;
import java.util.Objects;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
...@@ -559,6 +558,12 @@ public class FilterEntry extends GsonPropertyObject { ...@@ -559,6 +558,12 @@ public class FilterEntry extends GsonPropertyObject {
p = cb.and(p, cb.notLike(root.get(Item_.stringShortValue), "%" + compareValue + "%")); p = cb.and(p, cb.notLike(root.get(Item_.stringShortValue), "%" + compareValue + "%"));
} else if (Comparison.isBetween(this.comparison)) { } else if (Comparison.isBetween(this.comparison)) {
p = cb.and(p, cb.between(root.get(Item_.stringShortValue), compareValue, compareOtherValue)); p = cb.and(p, cb.between(root.get(Item_.stringShortValue), compareValue, compareOtherValue));
} else if (Comparison.isIsMember(this.comparison)) {
if(compareValue.indexOf(",") > -1){
p = cb.and(p, root.get(Item_.stringShortValue).in(Arrays.asList(compareValue.split(","))));
}else{
p = cb.and(p, cb.equal(root.get(Item_.stringShortValue), compareValue));
}
} else { } else {
p = cb.and(p, cb.equal(root.get(Item_.stringShortValue), compareValue)); p = cb.and(p, cb.equal(root.get(Item_.stringShortValue), compareValue));
} }
...@@ -974,6 +979,12 @@ public class FilterEntry extends GsonPropertyObject { ...@@ -974,6 +979,12 @@ public class FilterEntry extends GsonPropertyObject {
p = cb.and(p, cb.notLike(root.get(paramName), "%" + compareValue + "%")); p = cb.and(p, cb.notLike(root.get(paramName), "%" + compareValue + "%"));
} else if (Comparison.isBetween(this.comparison)) { } else if (Comparison.isBetween(this.comparison)) {
p = cb.and(p, cb.between(root.get(paramName), compareValue, compareOtherValue)); p = cb.and(p, cb.between(root.get(paramName), compareValue, compareOtherValue));
} else if (Comparison.isIsMember(this.comparison)) {
if(compareValue.indexOf(",") > -1){
p = cb.and(p, root.get(paramName).in(Arrays.asList(compareValue.split(","))));
}else{
p = cb.and(p, cb.equal(root.get(paramName), compareValue));
}
} else { } else {
p = cb.and(p, cb.equal(root.get(paramName), compareValue)); p = cb.and(p, cb.equal(root.get(paramName), compareValue));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册