feat(接口测试): mock筛选模块匹配转义问题

--bug=1047902 --user=宋昌昌 【接口测试】定义-MOCK-高级搜索-存在期望名称为「1·11_copy」的期望-筛选条件期望名称不等于「1·11_copy」-筛选后未过滤掉该期望 https://www.tapd.cn/55049933/s/1596629
This commit is contained in:
song-cc-rock 2024-10-23 16:45:33 +08:00 committed by Craftsman
parent 4dac67ad05
commit 03f384ab49
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,5 @@
package io.metersphere.system.interceptor; package io.metersphere.system.interceptor;
import io.metersphere.sdk.dto.BaseCondition; import io.metersphere.sdk.dto.BaseCondition;
import io.metersphere.sdk.dto.CombineCondition; import io.metersphere.sdk.dto.CombineCondition;
import io.metersphere.sdk.dto.CombineSearch; import io.metersphere.sdk.dto.CombineSearch;
@ -6,7 +7,7 @@ import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.JSON;
import io.metersphere.system.constants.InternalUserView; import io.metersphere.system.constants.InternalUserView;
import io.metersphere.system.dto.UserViewDTO; import io.metersphere.system.dto.UserViewDTO;
import io.metersphere.system.dto.sdk.*; import io.metersphere.system.dto.sdk.DBCombineSearch;
import io.metersphere.system.utils.SessionUtils; import io.metersphere.system.utils.SessionUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
@ -67,7 +68,8 @@ public class BaseConditionFilterAspect {
List<CombineCondition> validConditions = getValidConditions(combineSearch.getConditions()); List<CombineCondition> validConditions = getValidConditions(combineSearch.getConditions());
validConditions.forEach(item -> { validConditions.forEach(item -> {
if (item.getValue() != null && item.getValue() instanceof String strValue if (item.getValue() != null && item.getValue() instanceof String strValue
&& !StringUtils.equals(item.getOperator(), CombineCondition.CombineConditionOperator.EQUALS.name())) { && StringUtils.equalsAny(item.getOperator(), CombineCondition.CombineConditionOperator.CONTAINS.name(),
CombineCondition.CombineConditionOperator.NOT_CONTAINS.name())) {
// 转义 mysql 的特殊字符 // 转义 mysql 的特殊字符
item.setValue(BaseCondition.transferKeyword(strValue)); item.setValue(BaseCondition.transferKeyword(strValue));
} }