diff --git a/backend/framework/provider/src/main/java/io/metersphere/request/BaseProviderCondition.java b/backend/framework/provider/src/main/java/io/metersphere/request/BaseProviderCondition.java index 225e7bc63e..bcf9f392ba 100644 --- a/backend/framework/provider/src/main/java/io/metersphere/request/BaseProviderCondition.java +++ b/backend/framework/provider/src/main/java/io/metersphere/request/BaseProviderCondition.java @@ -2,6 +2,7 @@ package io.metersphere.request; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; @@ -19,4 +20,16 @@ public class BaseProviderCondition { @Schema(description = "高级搜索") private Map combine; + + // 转JSON时会调用。 前台数据传过来时可以顺便处理掉转义字符 + public void setKeyword(String keyword) { + keyword = StringUtils.replace(keyword, "%", "\\%"); + keyword = StringUtils.replace(keyword, "_", "\\_"); + this.keyword = keyword; + } + + // 直接初始化keyword + public void initKeyword(String keyword) { + this.keyword = keyword; + } }