diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index dc7a7081de..306fd61c94 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -130,10 +130,22 @@ public class APITestService { test.setScenarioDefinition(request.getScenarioDefinition()); test.setUpdateTime(System.currentTimeMillis()); test.setStatus(APITestStatus.Saved.name()); - /*checkApiTestPlanExist(test);*/ + checkApiTestExist(test); apiTestMapper.updateByPrimaryKeySelective(test); return test; } + + private void checkApiTestExist(ApiTest apiTest) { + if (apiTest.getName() != null) { + ApiTestExample example = new ApiTestExample(); + example.createCriteria() + .andNameEqualTo(apiTest.getName()); + if (apiTestMapper.selectByExample(example).size() > 0) { + MSException.throwException(Translator.get("api_test_name_already_exists")); + } + } + } + private ApiTestWithBLOBs createTest(SaveAPITestRequest request) { ApiTestExample example = new ApiTestExample(); example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9681fc1698..86437e2cd0 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -95,4 +95,5 @@ options=options please_input_workspace_member=Please input workspace merber test_case_report_template_repeat=The workspace has the same name template plan_name_already_exists=Test plan name already exists -test_case_already_exists_excel=There are duplicate test cases in the import file \ No newline at end of file +test_case_already_exists_excel=There are duplicate test cases in the import file +api_test_name_already_exists=Test name already exists \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index c2904033da..ffe808cb7d 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -96,3 +96,4 @@ please_input_workspace_member=请填写该工作空间相关人员 test_case_report_template_repeat=同一工作空间下不能存在同名模版 plan_name_already_exists=测试计划名称已存在 test_case_already_exists_excel=导入文件中存在重复用例 +api_test_name_already_exists=测试名称已经存在 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 1a9aa1ddef..842c0a6016 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -95,4 +95,5 @@ options=選項 please_input_workspace_member=請填寫該工作空間相關人員 test_case_report_template_repeat=同壹工作空間下不能存在同名模版 plan_name_already_exists=測試計劃名稱已存在 -test_case_already_exists_excel=導入文件中存在重復用例 \ No newline at end of file +test_case_already_exists_excel=導入文件中存在重復用例 +api_test_name_already_exists=測試名稱已經存在 \ No newline at end of file