add 公共方法,修改SQL查询中的%

This commit is contained in:
lijiarao
2021-10-11 15:46:48 +08:00
parent b198ad270a
commit 23b7b41770
2 changed files with 13 additions and 0 deletions
@@ -482,6 +482,12 @@ public class QueryGenerator {
if (value == null || rule == null || oConvertUtils.isEmpty(value)) {
return;
}
//对"_"与"%"的替换
if (value instanceof String){
value = ((String) value).replaceAll("_", "\\\\_").replaceAll("%","\\\\%");
}
name = oConvertUtils.camelToUnderline(name);
log.info("--查询规则-->"+name+" "+rule.getValue()+" "+value);
switch (rule) {
@@ -665,4 +665,11 @@ public class oConvertUtils {
}
return json;
}
/**
* sql查询时替换所有%
*/
public static String replaceAllPercent(String value){
return value.replaceAll("%","\\\\%");
}
}