fix(接口定义): 修复场景导入会创建同名模块的缺陷

--bug=1018384 --user=王孝刚
【接口测试】接口自动化将模块放入未规划后再放回与未规划同级别,然后再导入文件「导入文件存在相同模块」导入后回新建同名模块
https://www.tapd.cn/55049933/s/1266679
This commit is contained in:
wxg0103 2022-10-18 19:30:38 +08:00 committed by wxg0103
parent 590fa157ef
commit 32f99979e4
1 changed files with 3 additions and 17 deletions

View File

@ -2,11 +2,7 @@ package io.metersphere.service.scenario;
import io.metersphere.api.dto.ApiTestImportRequest; import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.automation.ApiScenarioDTO; import io.metersphere.api.dto.automation.*;
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.DragApiScenarioModuleRequest;
import io.metersphere.api.dto.automation.UpdateScenarioModuleDTO;
import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioModule; import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.base.domain.ApiScenarioModuleExample; import io.metersphere.base.domain.ApiScenarioModuleExample;
@ -38,17 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -925,7 +911,7 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
int i = 0; int i = 0;
Map<String, List<ApiScenarioModule>> idModuleMap = new HashMap<>(); Map<String, List<ApiScenarioModule>> idModuleMap = new HashMap<>();
for (ApiScenarioModuleDTO scenarioModuleDTO : nodeTreeByProjectId) { for (ApiScenarioModuleDTO scenarioModuleDTO : nodeTreeByProjectId) {
if (StringUtils.isBlank(scenarioModuleDTO.getParentId())) { if (StringUtils.isBlank(scenarioModuleDTO.getParentId()) || StringUtils.equals(scenarioModuleDTO.getParentId(), "0")) {
scenarioModuleDTO.setParentId(PropertyConstant.ROOT); scenarioModuleDTO.setParentId(PropertyConstant.ROOT);
} }
String parentModulePath = parentModulePathMap.get(scenarioModuleDTO.getParentId()); String parentModulePath = parentModulePathMap.get(scenarioModuleDTO.getParentId());