fix(接口测试): 高级搜索没有处理关键字中的特殊字符
--bug=1046882 --user=陈建星 【通用功能】筛选-输入文本框中输入反斜杠搜索不到结果 https://www.tapd.cn/55049933/s/1583260
This commit is contained in:
parent
90ae8efacd
commit
18997cdda7
|
@ -29,7 +29,15 @@ public class BaseCondition {
|
|||
private Map<String, Object> combine;
|
||||
|
||||
// 转JSON时会调用。 前台数据传过来时可以顺便处理掉转义字符
|
||||
@Deprecated
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = transferKeyword(keyword);
|
||||
}
|
||||
|
||||
public static String transferKeyword(String keyword) {
|
||||
if (StringUtils.contains(keyword, "\\") && !StringUtils.contains(keyword, "\\\\")) {
|
||||
keyword = StringUtils.replace(keyword, "\\", "\\\\");
|
||||
}
|
||||
//判断之前有没有转义过。转义过就不再转义。耍花活的自己想办法解决
|
||||
if (StringUtils.contains(keyword, "%") && !StringUtils.contains(keyword, "\\%")) {
|
||||
keyword = StringUtils.replace(keyword, "%", "\\%");
|
||||
|
@ -37,7 +45,7 @@ public class BaseCondition {
|
|||
if (StringUtils.contains(keyword, "_") && !StringUtils.contains(keyword, "\\_")) {
|
||||
keyword = StringUtils.replace(keyword, "_", "\\_");
|
||||
}
|
||||
this.keyword = keyword;
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void initKeyword(String keyword) {
|
||||
|
|
|
@ -65,6 +65,12 @@ public class BaseConditionFilterAspect {
|
|||
return;
|
||||
}
|
||||
List<CombineCondition> validConditions = getValidConditions(combineSearch.getConditions());
|
||||
validConditions.forEach(item -> {
|
||||
if (item.getValue() != null && item.getValue() instanceof String strValue) {
|
||||
// 转义 mysql 的特殊字符
|
||||
item.setValue(BaseCondition.transferKeyword(strValue));
|
||||
}
|
||||
});
|
||||
replaceCurrentUser(validConditions);
|
||||
List<CombineCondition> systemFieldConditions = validConditions.stream()
|
||||
.filter(item -> !BooleanUtils.isTrue(item.getCustomField()))
|
||||
|
|
Loading…
Reference in New Issue