fix(项目设置): 公共脚本重名校验有误

This commit is contained in:
AgAngle 2024-02-26 10:47:10 +08:00 committed by jianxing
parent bc63de118d
commit d3c02a4264
2 changed files with 3 additions and 1 deletions

View File

@ -53,7 +53,7 @@ public abstract class ScriptProcessorConverter extends MsProcessorConverter<Scri
scriptLanguage = scriptProcessor.getCommonScriptInfo().getScriptLanguage(); scriptLanguage = scriptProcessor.getCommonScriptInfo().getScriptLanguage();
script = scriptProcessor.getCommonScriptInfo().getScript(); script = scriptProcessor.getCommonScriptInfo().getScript();
} }
if (scriptLanguage == null) { if (scriptLanguage == null || StringUtils.equalsIgnoreCase(scriptLanguage, ScriptLanguageType.BEANSHELL_JSR233.name())) {
scriptLanguage = ScriptLanguageType.BEANSHELL.name(); scriptLanguage = ScriptLanguageType.BEANSHELL.name();
} }
testElement.setProperty(JmeterProperty.SCRIPT, script); testElement.setProperty(JmeterProperty.SCRIPT, script);

View File

@ -147,6 +147,7 @@ public class CustomFunctionService {
private void checkAddExist(CustomFunction customFunction) { private void checkAddExist(CustomFunction customFunction) {
CustomFunctionExample example = new CustomFunctionExample(); CustomFunctionExample example = new CustomFunctionExample();
example.createCriteria() example.createCriteria()
.andProjectIdEqualTo(customFunction.getProjectId())
.andNameEqualTo(customFunction.getName()); .andNameEqualTo(customFunction.getName());
if (customFunctionMapper.countByExample(example) > 0) { if (customFunctionMapper.countByExample(example) > 0) {
throw new MSException(ProjectResultCode.CUSTOM_FUNCTION_ALREADY_EXIST); throw new MSException(ProjectResultCode.CUSTOM_FUNCTION_ALREADY_EXIST);
@ -156,6 +157,7 @@ public class CustomFunctionService {
private void checkUpdateExist(CustomFunction customFunction) { private void checkUpdateExist(CustomFunction customFunction) {
CustomFunctionExample example = new CustomFunctionExample(); CustomFunctionExample example = new CustomFunctionExample();
example.createCriteria() example.createCriteria()
.andProjectIdEqualTo(customFunction.getProjectId())
.andIdNotEqualTo(customFunction.getId()) .andIdNotEqualTo(customFunction.getId())
.andNameEqualTo(customFunction.getName()); .andNameEqualTo(customFunction.getName());
if (customFunctionMapper.countByExample(example) > 0) { if (customFunctionMapper.countByExample(example) > 0) {