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 8846966566..f7eb907fb0 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -467,6 +467,7 @@ public class ApiModuleService extends NodeTreeService { node.setCreateTime(System.currentTimeMillis()); node.setUpdateTime(System.currentTimeMillis()); node.setId(UUID.randomUUID().toString()); + node.setCreateUser(SessionUtils.getUserId()); apiModuleMapper.insertSelective(node); return node; } @@ -538,6 +539,7 @@ public class ApiModuleService extends NodeTreeService { record.setCreateTime(System.currentTimeMillis()); record.setUpdateTime(System.currentTimeMillis()); record.setProjectId(projectId); + record.setCreateUser(SessionUtils.getUserId()); apiModuleMapper.insert(record); return record; }else { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 4fdf026c46..208d1cc11d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -465,6 +465,7 @@ public class ApiScenarioModuleService extends NodeTreeService { List list = testCaseNodeMapper.selectByExample(example); if(CollectionUtils.isEmpty(list)){ NodeNumDTO record = new NodeNumDTO(); - //TestCaseNode record = new TestCaseNode(); record.setId(UUID.randomUUID().toString()); record.setCreateUser(SessionUtils.getUserId()); record.setName("未规划用例"); @@ -144,34 +143,11 @@ public class TestCaseNodeService extends NodeTreeService { public List getNodeTreeByProjectId(String projectId) { // 判断当前项目下是否有默认模块,没有添加默认模块 this.getDefaultNode(projectId); -// TestCaseNodeExample example = new TestCaseNodeExample(); -// example.createCriteria().andProjectIdEqualTo(projectId).andNameEqualTo("默认模块"); -// long count = testCaseNodeMapper.countByExample(example); -// if (count <= 0) { -// NodeNumDTO record = new NodeNumDTO(); -// //TestCaseNode record = new TestCaseNode(); -// record.setId(UUID.randomUUID().toString()); -// record.setCreateUser(SessionUtils.getUserId()); -// record.setName("默认模块"); -// record.setPos(1.0); -// record.setLevel(1); -// record.setCreateTime(System.currentTimeMillis()); -// record.setUpdateTime(System.currentTimeMillis()); -// record.setProjectId(projectId); -// testCaseNodeMapper.insert(record); -// record.setCaseNum(0); -// } List testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId); QueryTestCaseRequest request = new QueryTestCaseRequest(); request.setUserId(SessionUtils.getUserId()); request.setProjectId(projectId); -// for (TestCaseNodeDTO node : testCaseNodes) { -// List nodeIds = new ArrayList<>(); -// nodeIds = this.nodeList(testCaseNodes, node.getId(), nodeIds); -// nodeIds.add(node.getId()); -// request.setNodeIds(nodeIds); -// node.setCaseNum(extTestCaseMapper.moduleCount(request)); -// } + //优化:将for循环内的SQL抽出来,只差一次 List allModuleIdList = new ArrayList<>(); for (TestCaseNodeDTO node : testCaseNodes) { @@ -464,6 +440,7 @@ public class TestCaseNodeService extends NodeTreeService { testCaseNode.setCreateTime(System.currentTimeMillis()); testCaseNode.setUpdateTime(System.currentTimeMillis()); testCaseNode.setLevel(level); + testCaseNode.setCreateUser(SessionUtils.getUserId()); testCaseNode.setId(UUID.randomUUID().toString()); double pos = getNextLevelPos(projectId, level, pId); testCaseNode.setPos(pos);