From 1a7cd30872044c751cf1be01cf3b6d1a74198118 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 28 Mar 2023 17:40:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=E8=A7=A3=E5=86=B3url=E4=B8=8D=E9=87=8D=E5=A4=8Dapi=5Fmodule?= =?UTF-8?q?=E6=A0=91=E7=94=9F=E6=88=90=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024415 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001024415 --- .../ApiDefinitionImportUtilService.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java index cfa973d8e8..f738e8a156 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionImportUtilService.java @@ -386,7 +386,7 @@ public class ApiDefinitionImportUtilService { ApiTestImportRequest request = apiImportParamDto.getRequest(); List optionData = apiImportParamDto.getOptionData(); ApiModuleDTO chooseModule = apiImportParamDto.getChooseModule(); - Map idPathMap = apiImportParamDto.getIdPathMap(); + Map moduleIdPathMap = apiImportParamDto.getIdPathMap(); Boolean fullCoverage = apiImportParamDto.getFullCoverage(); List toUpdateList = apiImportParamDto.getToUpdateList(); List optionDataCases = apiImportParamDto.getOptionDataCases(); @@ -413,7 +413,7 @@ public class ApiDefinitionImportUtilService { if (chooseModule != null) { //如果有选中的模块,则在选中的模块下过滤 过滤规则是 选择的模块路径+名称+method+path String chooseModuleParentId = getChooseModuleParentId(chooseModule); - String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId); + String chooseModulePath = getChooseModulePath(moduleIdPathMap, chooseModule, chooseModuleParentId); //这样的过滤规则下可能存在重复接口,如果是覆盖模块,需要按照去重规则再次去重,否则就加上接口原有的模块 if (fullCoverage) { removeHttpChooseModuleRepeat(optionData, chooseModulePath); @@ -829,7 +829,7 @@ public class ApiDefinitionImportUtilService { ApiTestImportRequest request = apiImportParamDto.getRequest(); List optionData = apiImportParamDto.getOptionData(); ApiModuleDTO chooseModule = apiImportParamDto.getChooseModule(); - Map idPathMap = apiImportParamDto.getIdPathMap(); + Map moduleIdPathMap = apiImportParamDto.getIdPathMap(); Boolean fullCoverage = apiImportParamDto.getFullCoverage(); List toUpdateList = apiImportParamDto.getToUpdateList(); List optionDataCases = apiImportParamDto.getOptionDataCases(); @@ -851,7 +851,7 @@ public class ApiDefinitionImportUtilService { if (chooseModule != null) { String chooseModuleParentId = getChooseModuleParentId(chooseModule); - String chooseModulePath = getChooseModulePath(idPathMap, chooseModule, chooseModuleParentId); + String chooseModulePath = getChooseModulePath(moduleIdPathMap, chooseModule, chooseModuleParentId); if (fullCoverage) { List singleOptionData = new ArrayList<>(); removeOtherChooseModuleRepeat(optionData, singleOptionData, chooseModulePath); @@ -1090,7 +1090,10 @@ public class ApiDefinitionImportUtilService { private void removeSameData(Map> repeatDataMap, Map methodPathMap, List optionData, Map moduleMap, List optionDataCases) { - + Map parentIdModuleMap = new HashMap<>(); + for (ApiModule value : moduleMap.values()) { + parentIdModuleMap.put(value.getParentId(), value); + } Map> moduleOptionData = optionData.stream().collect(Collectors.groupingBy(ApiDefinition::getModulePath)); repeatDataMap.forEach((k, v) -> { ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = methodPathMap.get(k); @@ -1100,7 +1103,10 @@ public class ApiDefinitionImportUtilService { String modulePath = apiDefinitionWithBLOBs.getModulePath(); List moduleData = moduleOptionData.get(modulePath); if (moduleData != null && moduleData.size() <= 1) { - moduleMap.remove(modulePath); + ApiModule apiModule = moduleMap.get(modulePath); + if (parentIdModuleMap.get(apiModule.getId()) == null) { + moduleMap.remove(modulePath); + } moduleData.remove(apiDefinitionWithBLOBs); } //不覆盖同一接口不做更新 注意原接口的update时间不变