From 6cb785ed132fff23f30887245f0b9b0b85e97639 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 8 Jul 2022 18:47:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=9B=E5=BB=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../java/io/metersphere/api/service/ApiAutomationService.java | 2 +- .../java/io/metersphere/api/service/ApiDefinitionService.java | 3 +-- .../main/java/io/metersphere/api/service/ApiModuleService.java | 2 +- .../io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java | 2 +- .../io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml | 1 + 5 files changed, 5 insertions(+), 5 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 7c965fe411..6f373af9c0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1289,6 +1289,7 @@ public class ApiAutomationService { if (StringUtils.equals("fullCoverage", apiTestImportRequest.getModeId())) { _importCreate(sameList, batchMapper, extApiScenarioMapper, scenarioWithBLOBs, apiTestImportRequest, apiTestCaseMapper, apiDefinitionMapper); } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) { + scenarioWithBLOBs.setId(UUID.randomUUID().toString()); if (CollectionUtils.isEmpty(sameList)) { if (scenarioWithBLOBs.getVersionId() != null && scenarioWithBLOBs.getVersionId().equals("new")) { scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); @@ -1297,7 +1298,6 @@ public class ApiAutomationService { scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId()); scenarioWithBLOBs.setLatest(true); } - scenarioWithBLOBs.setId(UUID.randomUUID().toString()); if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) { scenarioWithBLOBs.setVersionId(apiTestImportRequest.getVersionId()); } else { 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 4643c2163a..6f4bf7f211 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -785,6 +785,7 @@ public class ApiDefinitionService { } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) { if (CollectionUtils.isEmpty(collect)) { String originId = apiDefinition.getId(); + apiDefinition.setId(UUID.randomUUID().toString()); //postman 可能含有前置脚本,接口定义去掉脚本 if (apiDefinition.getVersionId() != null && apiDefinition.getVersionId().equals("new")) { apiDefinition.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion())); @@ -793,7 +794,6 @@ public class ApiDefinitionService { apiDefinition.setRefId(apiDefinition.getId()); apiDefinition.setLatest(true); // 新增的接口 latest = true } - apiDefinition.setId(UUID.randomUUID().toString()); if (StringUtils.isNotEmpty(apiTestImportRequest.getVersionId())) { apiDefinition.setVersionId(apiTestImportRequest.getVersionId()); } else { @@ -801,7 +801,6 @@ public class ApiDefinitionService { } batchMapper.insert(apiDefinition); String requestStr = setImportHashTree(apiDefinition); - // case 设置版本 cases.forEach(c -> { c.setVersionId(apiDefinition.getVersionId()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index ca88818846..89ec75d922 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -749,7 +749,7 @@ public class ApiModuleService extends NodeTreeService { List nameList = optionData.stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList()); //获取系统内重复数据 - repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByProtocol(nameList, protocol); + repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByProtocol(nameList, protocol, projectId); Map repeatDataMap = null; diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index 612d84f17b..44b0ba2662 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -95,6 +95,6 @@ public interface ExtApiDefinitionMapper { List selectRepeatByBLOBsSameUrl(@Param("blobs") List blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId); - List selectRepeatByProtocol(@Param("names") List names, @Param("protocol") String protocol); + List selectRepeatByProtocol(@Param("names") List names, @Param("protocol") String protocol, @Param("projectId") String projectId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index b6c6fbb315..06ae4df1c7 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -1010,6 +1010,7 @@ #{name} and protocol = #{protocol} + and project_id = #{projectId} and status != 'Trash'