diff --git a/backend/src/main/java/io/metersphere/service/NodeTreeService.java b/backend/src/main/java/io/metersphere/service/NodeTreeService.java index bd8d0c8989..7ea650d36c 100644 --- a/backend/src/main/java/io/metersphere/service/NodeTreeService.java +++ b/backend/src/main/java/io/metersphere/service/NodeTreeService.java @@ -170,7 +170,7 @@ public class NodeTreeService { path.append("/" + nodeName); - String pid = null; + String pid; //创建过不创建 if (pathMap.get(path.toString()) != null) { pid = pathMap.get(path.toString()); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java index fa9ec5df5f..f1bc6e0380 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseNodeService.java @@ -405,7 +405,7 @@ public class TestCaseNodeService extends NodeTreeService { List nodeNameList = new ArrayList<>(Arrays.asList(item.split("/"))); Iterator itemIterator = nodeNameList.iterator(); Boolean hasNode = false; - String rootNodeName = null; + String rootNodeName; if (nodeNameList.size() <= 1) { throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index f09a9fe959..58cb8bc683 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -937,6 +937,17 @@ public class TestCaseService { testCase.setCreateUser(SessionUtils.getUserId()); testCase.setCreateTime(System.currentTimeMillis()); testCase.setUpdateTime(System.currentTimeMillis()); + if (StringUtils.isNotBlank(testCase.getNodePath())) { + String[] modules = testCase.getNodePath().split("/"); + StringBuilder path = new StringBuilder(); + for (String module : modules) { + if (StringUtils.isNotBlank(module)) { + path.append("/"); + path.append(module.trim()); + } + } + testCase.setNodePath(path.toString()); + } testCase.setNodeId(nodePathMap.get(testCase.getNodePath())); testCase.setNum(num); if (project.getCustomNum() && StringUtils.isBlank(testCase.getCustomNum())) {