From ab79efcdf2288c390624717af7b77f75e62396ba Mon Sep 17 00:00:00 2001 From: MeterSphere Bot <78466014+metersphere-bot@users.noreply.github.com> Date: Wed, 13 Jul 2022 18:47:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E3=80=81=E5=9C=BA=E6=99=AF=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E7=A7=BB=E5=8A=A8=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20(#15729)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1014783 --user=王孝刚 【接口测试】接口、场景批量移动,没有校验接口是否重复 https://www.tapd.cn/55049933/s/1200080 Co-authored-by: wxg0103 <727495428@qq.com> --- .../api/service/ApiAutomationService.java | 17 ++++++++++++++ .../api/service/ApiDefinitionService.java | 22 +++++++++++++++++++ .../resources/i18n/messages_en_US.properties | 2 +- .../resources/i18n/messages_zh_CN.properties | 2 +- .../resources/i18n/messages_zh_TW.properties | 2 +- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index ba06d62c15..0364e012b1 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1137,6 +1137,23 @@ public class ApiAutomationService { ApiScenarioWithBLOBs apiScenarioWithBLOBs = new ApiScenarioWithBLOBs(); BeanUtils.copyBean(apiScenarioWithBLOBs, request); apiScenarioWithBLOBs.setUpdateTime(System.currentTimeMillis()); + if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) { + request.getIds().forEach(apiId -> { + ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(apiId); + if (scenario == null) { + return; + } + //检查是否同名 + SaveApiScenarioRequest scenarioRequest = new SaveApiScenarioRequest(); + scenarioRequest.setProjectId(scenario.getProjectId()); + scenarioRequest.setName(scenario.getName()); + scenarioRequest.setId(scenario.getId()); + scenarioRequest.setApiScenarioModuleId(request.getApiScenarioModuleId()); + scenarioRequest.setModulePath(request.getModulePath()); + scenarioRequest.setVersionId(scenario.getVersionId()); + checkNameExist(scenarioRequest, false); + }); + } apiScenarioMapper.updateByExampleSelective( apiScenarioWithBLOBs, apiScenarioExample); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 9536efdf15..d0e82c0d76 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1651,6 +1651,28 @@ public class ApiDefinitionService { ApiDefinitionWithBLOBs definitionWithBLOBs = new ApiDefinitionWithBLOBs(); BeanUtils.copyBean(definitionWithBLOBs, request); definitionWithBLOBs.setUpdateTime(System.currentTimeMillis()); + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> extApiDefinitionMapper.selectIds(query)); + if (request != null && (request.getIds() != null || !request.getIds().isEmpty())) { + request.getIds().forEach(apiId -> { + ApiDefinitionWithBLOBs api = apiDefinitionMapper.selectByPrimaryKey(apiId); + if (api == null) { + return; + } + //检查是否同名 + SaveApiDefinitionRequest apiDefinitionRequest = new SaveApiDefinitionRequest(); + apiDefinitionRequest.setProjectId(api.getProjectId()); + apiDefinitionRequest.setMethod(api.getMethod()); + apiDefinitionRequest.setProtocol(api.getProtocol()); + apiDefinitionRequest.setPath(api.getPath()); + apiDefinitionRequest.setName(api.getName()); + apiDefinitionRequest.setId(api.getId()); + apiDefinitionRequest.setModuleId(request.getModuleId()); + apiDefinitionRequest.setModulePath(request.getModulePath()); + apiDefinitionRequest.setVersionId(api.getVersionId()); + checkNameExist(apiDefinitionRequest, false); + }); + } apiDefinitionMapper.updateByExampleSelective(definitionWithBLOBs, getBatchExample(request)); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 65a6efc724..4a5c64a697 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -227,7 +227,7 @@ upload_content_is_null=Imported content is empty test_plan_notification=Test plan notification task_defect_notification=Task defect notification task_notification_=Timing task result notification -api_definition_url_not_repeating=The interface request address already exists under the same module +api_definition_url_not_repeating=The interface request address already exists api_definition_name_not_repeating=The same name-url combination already exists under the same module api_definition_name_already_exists=Interface names under the same module cannot be repeated api_definition_module=The module path is diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 494a926807..853d4630f3 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -227,7 +227,7 @@ upload_content_is_null=导入内容为空 test_plan_notification=测试计划通知 task_defect_notification=缺陷任务通知 task_notification_=定时任务结果通知 -api_definition_url_not_repeating=同一模块下接口请求地址已经存在 +api_definition_url_not_repeating=接口请求地址已经存在 api_definition_name_not_repeating=同一模块下相同的名称-url组合已存在 api_definition_name_already_exists=同一模块下接口名称不能重复 api_definition_module=模块路径为 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index cd774f1974..14996c86ac 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -226,7 +226,7 @@ upload_content_is_null=導入內容為空 test_plan_notification=測試計劃通知 task_defect_notification=缺陷任務通知 task_notification_=定時任務結果通知 -api_definition_url_not_repeating=同一模塊下介面請求地址已經存在 +api_definition_url_not_repeating=介面請求地址已經存在 api_definition_name_not_repeating=同一模塊下相同的名稱-url組合已存在 api_definition_name_already_exists=同一模塊下介面名稱不能重複 api_definition_module=模塊路徑為