feat: 文本搜索增加与或条件,精准、模糊匹配

This commit is contained in:
junjun 2024-04-10 13:57:54 +08:00
parent aebaac3baf
commit 0145f67d7d

View File

@ -102,7 +102,13 @@ public class ExtWhere2Str {
String whereTerm = Utils.transFilterTerm(request.getOperator());
String whereValue = "";
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if (StringUtils.containsIgnoreCase(request.getOperator(), "-")) {
String[] split = request.getOperator().split("-");
String term1 = split[0];
String logic = split[1];
String term2 = split[2];
whereValue = term1 + getValue(term1, value.get(0)) + logic + whereName + term2 + getValue(term2, value.get(1));
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
// 过滤空数据
if (value.contains(SQLConstants.EMPTY_SIGN)) {
whereValue = "('" + StringUtils.join(value, "','") + "', '')" + " or " + whereName + " is null ";
@ -144,4 +150,14 @@ public class ExtWhere2Str {
meta.setExtWheresDialect(fieldsDialect);
}
private static String getValue(String term, String value) {
switch (term) {
case "like":
return "'%" + value + "%'";
case "eq":
return "'" + value + "'";
}
return null;
}
}