From b7b25876df5b09ff0a695c0e6e456b0a36a8b53e Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 19 Jan 2022 15:19:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E5=9C=A8?= =?UTF-8?q?url=E4=B8=8D=E5=8F=AF=E9=87=8D=E5=A4=8D=E7=9A=84=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E4=B8=8B=E8=BF=9B=E8=A1=8C=E6=89=B9=E9=87=8F=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=97=B6=E8=83=BD=E5=A4=8D=E5=88=B6=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009744 --user=宋天阳 【接口定义】-接口定义URL不可重复-批量复制接口到其他模块成功,未提示接口地址重复 https://www.tapd.cn/55049933/s/1094257 --- .../metersphere/api/service/ApiDefinitionService.java | 8 ++++---- .../java/io/metersphere/service/ProjectService.java | 11 +++++++++++ .../src/main/resources/i18n/messages_en_US.properties | 2 ++ .../src/main/resources/i18n/messages_zh_CN.properties | 2 ++ .../src/main/resources/i18n/messages_zh_TW.properties | 2 ++ 5 files changed, 21 insertions(+), 4 deletions(-) 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 698d38bdfd..608ca5508e 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -46,10 +46,7 @@ import io.metersphere.log.vo.StatusReference; import io.metersphere.log.vo.api.DefinitionReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; -import io.metersphere.service.FileService; -import io.metersphere.service.QuotaService; -import io.metersphere.service.RelationshipEdgeService; -import io.metersphere.service.ScheduleService; +import io.metersphere.service.*; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.service.TestPlanService; @@ -1870,6 +1867,9 @@ public class ApiDefinitionService { } public void batchCopy(ApiBatchRequest request) { + //检查测试项目是否开启了url可重复 + ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class); + projectService.checkProjectIsRepeatable(request.getProjectId()); ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiDefinitionMapper.selectIds(query)); List ids = request.getIds(); diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index d253f307d0..b217b83cf0 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -860,4 +860,15 @@ public class ProjectService { } performanceReportService.cleanUpReport(time, projectId); } + + public void checkProjectIsRepeatable(String projectId) { + Project project = this.getProjectById(projectId); + if(project == null){ + MSException.throwException(Translator.get("cannot_find_project")); + }else { + if(!project.getRepeatable()){ + MSException.throwException(Translator.get("project_repeatable_is_false")); + } + } + } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index e9ac461021..d9aac155cf 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -290,6 +290,8 @@ zentao_test_type_error=invalid Zentao request #项目报告 enterprise_test_report=Enterprise report count=Count +cannot_find_project=Cannot find project +project_repeatable_is_false=Url repeatable not open #环境组 null_environment_group_name = Environment group name is null environment_group_name = Environment group name diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 40370bbb1f..4074c377bd 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -289,6 +289,8 @@ zentao_test_type_error=无效的 Zentao 请求 #项目报告 enterprise_test_report=项目报告 count=统计 +cannot_find_project=未找到测试项目 +project_repeatable_is_false=项目未配置URL可重复 #环境组 null_environment_group_name = 环境组名称不存在 environment_group_name = 环境组名称 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 3188722a4c..6c0308fbd4 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -289,6 +289,8 @@ zentao_test_type_error=請求方式錯誤 #项目报告 enterprise_test_report=項目報告 count=統計 +cannot_find_project=未找到測試項目 +project_repeatable_is_false=項目未配置URL可重複 #环境组 null_environment_group_name = 環境組名稱不存在 environment_group_name = 環境組名稱