diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java index 45d163b798..8f95eee296 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java @@ -61,12 +61,12 @@ public class CaseReviewFunctionalCaseController { } - @GetMapping("/tree/{projectId}/{reviewId}") + @GetMapping("/tree/{reviewId}") @Operation(summary = "用例管理-用例评审-评审列表-评审详情-已关联用例列表模块树") @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) - @CheckOwner(resourceId = "#projectId", resourceType = "project") - public List getTree(@PathVariable String projectId, @PathVariable String reviewId) { - return caseReviewFunctionalCaseService.getTree(projectId, reviewId); + @CheckOwner(resourceId = "#reviewId", resourceType = "case_review") + public List getTree(@PathVariable String reviewId) { + return caseReviewFunctionalCaseService.getTree(reviewId); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleCountDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleCountDTO.java new file mode 100644 index 0000000000..acc0a60edd --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleCountDTO.java @@ -0,0 +1,16 @@ +package io.metersphere.functional.dto; + +import io.metersphere.project.dto.ModuleCountDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class FunctionalCaseModuleCountDTO extends ModuleCountDTO { + @Schema(description = "项目id") + private String projectId; + + @Schema(description = "项目名称") + private String projectName; + + +} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleDTO.java new file mode 100644 index 0000000000..8473ddb2f8 --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseModuleDTO.java @@ -0,0 +1,11 @@ +package io.metersphere.functional.dto; + +import io.metersphere.functional.domain.FunctionalCaseModule; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class FunctionalCaseModuleDTO extends FunctionalCaseModule { + @Schema(description = "项目名称") + private String projectName; +} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java index 8d1f5324b8..a6a47037eb 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.java @@ -1,12 +1,12 @@ package io.metersphere.functional.mapper; import io.metersphere.functional.domain.CaseReviewFunctionalCase; +import io.metersphere.functional.dto.FunctionalCaseModuleCountDTO; import io.metersphere.functional.dto.FunctionalCaseReviewDTO; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; import io.metersphere.functional.request.BaseReviewCaseBatchRequest; import io.metersphere.functional.request.FunctionalCaseReviewListRequest; import io.metersphere.functional.request.ReviewFunctionalCasePageRequest; -import io.metersphere.project.dto.ModuleCountDTO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -41,7 +41,8 @@ public interface ExtCaseReviewFunctionalCaseMapper { List getCaseIdsByIds(@Param("ids") List ids); - List countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId); + List countModuleIdByRequest(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId); long caseCount(@Param("request") ReviewFunctionalCasePageRequest request, @Param("deleted") boolean deleted, @Param("userId") String userId); + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml index f44220ae5a..843e7244ca 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtCaseReviewFunctionalCaseMapper.xml @@ -49,7 +49,6 @@ WHERE review_id = #{request.reviewId} AND functional_case.deleted = #{deleted} - AND functional_case.project_id = #{request.projectId} AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId}) @@ -382,14 +381,15 @@ - + SELECT functional_case.module_id AS moduleId, count(functional_case.id) AS dataCount, functional_case.project_id AS projectId, project.name AS projectName + FROM case_review_functional_case crfc + LEFT JOIN functional_case ON crfc.case_id = functional_case.id + LEFT JOIN project ON functional_case.project_id = project.id WHERE crfc.review_id = #{request.reviewId} AND functional_case.deleted = #{deleted} - AND functional_case.project_id = #{request.projectId} - AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId}) + AND crfc.case_id in (select crfcu.case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId}) @@ -410,7 +410,6 @@ FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id WHERE crfc.review_id = #{request.reviewId} AND functional_case.deleted = #{deleted} - AND functional_case.project_id = #{request.projectId} AND crfc.case_id in (select case_id from case_review_functional_case_user crfcu where crfcu.review_id = #{request.reviewId} and crfcu.user_id = #{userId}) @@ -426,4 +425,5 @@ + \ No newline at end of file diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.java b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.java index 50a512eea1..55ded00a27 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.java @@ -1,5 +1,6 @@ package io.metersphere.functional.mapper; +import io.metersphere.functional.dto.FunctionalCaseModuleDTO; import io.metersphere.project.dto.NodeSortQueryParam; import io.metersphere.request.AssociateCaseModuleRequest; import io.metersphere.system.dto.sdk.BaseModule; @@ -11,7 +12,7 @@ import java.util.List; public interface ExtFunctionalCaseModuleMapper { List selectBaseByProjectId(@Param("projectId")String projectId); - List selectBaseByProjectIdAndReviewId(@Param("projectId")String projectId, @Param("reviewId")String reviewId); + List selectBaseByProjectIdAndReviewId(@Param("reviewId")String reviewId); List selectBaseByIds(@Param("ids") List ids); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.xml index c97b0683e3..7bf20eef49 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseModuleMapper.xml @@ -7,11 +7,11 @@ WHERE project_id = #{projectId} ORDER BY pos - + SELECT fcm.id, fcm.project_id, p.name as projectName FROM functional_case_module fcm - WHERE fcm.project_id = #{projectId} - AND fcm.id IN + LEFT JOIN project p ON fcm.project_id = p.id + WHERE fcm.id IN (SELECT fc.module_id FROM functional_case fc LEFT JOIN case_review_functional_case crfc ON crfc.case_id = fc.id WHERE crfc.review_id = #{reviewId} AND fc.deleted = false) ORDER BY pos @@ -95,10 +95,9 @@ diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java index eb77e38da4..ae58cd4a3c 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java @@ -6,11 +6,10 @@ import io.metersphere.functional.constants.CaseFileSourceType; import io.metersphere.functional.constants.CaseReviewPassRule; import io.metersphere.functional.constants.FunctionalCaseReviewStatus; import io.metersphere.functional.domain.*; -import io.metersphere.functional.dto.CaseReviewHistoryDTO; -import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; -import io.metersphere.functional.dto.ReviewsDTO; +import io.metersphere.functional.dto.*; import io.metersphere.functional.mapper.*; import io.metersphere.functional.request.*; +import io.metersphere.project.domain.Project; import io.metersphere.project.domain.ProjectApplication; import io.metersphere.project.domain.ProjectApplicationExample; import io.metersphere.project.domain.ProjectVersion; @@ -18,8 +17,10 @@ import io.metersphere.project.dto.ModuleCountDTO; import io.metersphere.project.mapper.ExtBaseProjectVersionMapper; import io.metersphere.project.mapper.ProjectApplicationMapper; import io.metersphere.provider.BaseCaseProvider; +import io.metersphere.sdk.constants.ModuleConstants; import io.metersphere.sdk.constants.ProjectApplicationType; import io.metersphere.sdk.exception.MSException; +import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.sdk.BaseTreeNode; @@ -586,21 +587,51 @@ public class CaseReviewFunctionalCaseService { } } - public List getTree(String projectId, String reviewId) { - List functionalModuleIds = extFunctionalCaseModuleMapper.selectBaseByProjectIdAndReviewId(projectId, reviewId); - List nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(functionalModuleIds); - return functionalCaseModuleService.buildTreeAndCountResource(nodeByNodeIds, true, Translator.get("default.module")); + public List getTree(String reviewId) { + List returnList = new ArrayList<>(); + List functionalModuleIds = extFunctionalCaseModuleMapper.selectBaseByProjectIdAndReviewId(reviewId); + Map> projectModuleMap = functionalModuleIds.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getProjectId)); + projectModuleMap.forEach((projectId,moduleList)->{ + BaseTreeNode projectNode = new BaseTreeNode(projectId, moduleList.get(0).getProjectName(), Project.class.getName()); + returnList.add(projectNode); + List projectModuleIds = moduleList.stream().map(FunctionalCaseModule::getId).toList(); + List nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(projectModuleIds); + List list = nodeByNodeIds.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getId(), ModuleConstants.DEFAULT_NODE_ID.toString())).toList(); + boolean haveVirtualRootNode = list.isEmpty(); + List baseTreeNodes = functionalCaseModuleService.buildTreeAndCountResource(nodeByNodeIds, haveVirtualRootNode, Translator.get("default.module")); + for (BaseTreeNode baseTreeNode : baseTreeNodes) { + projectNode.addChild(baseTreeNode); + } + }); + return returnList; } public Map moduleCount(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) { //查出每个模块节点下的资源数量。 不需要按照模块进行筛选 request.setModuleIds(null); - List moduleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted, userId); - Map moduleCountMap = getModuleCountMap(request.getProjectId(), request.getReviewId(), moduleCountDTOList); + List projectModuleCountDTOList = extCaseReviewFunctionalCaseMapper.countModuleIdByRequest(request, deleted, userId); + Map> projectCountMap = projectModuleCountDTOList.stream().collect(Collectors.groupingBy(FunctionalCaseModuleCountDTO::getProjectId)); + Map projectModuleCountMap = new HashMap<>(); + projectCountMap.forEach((projectId,moduleCountDTOList)->{ + ListmoduleCountDTOS = new ArrayList<>(); + for (FunctionalCaseModuleCountDTO functionalCaseModuleCountDTO : moduleCountDTOList) { + ModuleCountDTO moduleCountDTO = new ModuleCountDTO(); + BeanUtils.copyBean(moduleCountDTO,functionalCaseModuleCountDTO); + moduleCountDTOS.add(moduleCountDTO); + } + int sum = moduleCountDTOList.stream().mapToInt(FunctionalCaseModuleCountDTO::getDataCount).sum(); + Map moduleCountMap = getModuleCountMap(projectId, request.getReviewId(), moduleCountDTOS); + moduleCountMap.forEach((k,v)->{ + if (projectModuleCountMap.get(k)==null || projectModuleCountMap.get(k) == 0L){ + projectModuleCountMap.put(k,v); + } + }); + projectModuleCountMap.put(projectId, (long)sum); + }); //查出全部用例数量 long allCount = extCaseReviewFunctionalCaseMapper.caseCount(request, deleted, userId); - moduleCountMap.put(CASE_MODULE_COUNT_ALL, allCount); - return moduleCountMap; + projectModuleCountMap.put(CASE_MODULE_COUNT_ALL, allCount); + return projectModuleCountMap; } /** @@ -609,6 +640,7 @@ public class CaseReviewFunctionalCaseService { public Map getModuleCountMap(String projectId, String reviewId, List moduleCountDTOList) { //构建模块树,并计算每个节点下的所有数量(包含子节点) List treeNodeList = this.getTreeOnlyIdsAndResourceCount(projectId, reviewId, moduleCountDTOList); + //通过广度遍历的方式构建返回值 return functionalCaseModuleService.getIdCountMapByBreadth(treeNodeList); } diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java index 6fbe403801..faaa254dae 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java @@ -7,7 +7,6 @@ import io.metersphere.functional.domain.CaseReviewFunctionalCaseExample; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.request.*; -import io.metersphere.sdk.constants.ModuleConstants; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BaseTest; @@ -142,17 +141,26 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { @Test @Order(4) public void emptyDataTest() throws Exception { - //空数据下,检查模块树 - List treeNodes = this.getCaseReviewModuleTreeNode("wx_test_project","wx_review_id_1"); - //检查有没有默认节点 - boolean hasNode = false; - for (BaseTreeNode baseTreeNode : treeNodes) { - if (StringUtils.equals(baseTreeNode.getId(), ModuleConstants.DEFAULT_NODE_ID)) { - hasNode = true; - } - Assertions.assertNotNull(baseTreeNode.getParentId()); - } - Assertions.assertTrue(hasNode); + List treeNodes = this.getCaseReviewModuleTreeNode("wx_test_project","wx_review_id_2"); + String jsonString = JSON.toJSONString(treeNodes); + System.out.println(jsonString); + Assertions.assertTrue(CollectionUtils.isNotEmpty(treeNodes)); + ReviewFunctionalCasePageRequest request = new ReviewFunctionalCasePageRequest(); + request.setReviewId("wx_review_id_2"); + request.setProjectId("wx_test_project"); + request.setCurrent(1); + request.setPageSize(10); + MvcResult mvcResult = this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request); + Map moduleCountResult = JSON.parseObject(JSON.toJSONString( + JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), + Map.class); + System.out.println(JSON.toJSONString(moduleCountResult)); + + MvcResult mvcResultPage = this.requestPostWithOkAndReturn(REVIEW_CASE_PAGE, request); + Pager> tableData = JSON.parseObject(JSON.toJSONString( + JSON.parseObject(mvcResultPage.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), + Pager.class); + System.out.println(JSON.toJSONString(tableData.getList())); } @@ -404,7 +412,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { private List getCaseReviewModuleTreeNode(String projectId, String reviewId) throws Exception { - MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(URL_MODULE_TREE+"/"+projectId+"/"+reviewId).header(SessionConstants.HEADER_TOKEN, sessionId) + MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(URL_MODULE_TREE+"/"+reviewId).header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CURRENT_PROJECT, projectId) .contentType(MediaType.APPLICATION_JSON)) diff --git a/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql b/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql index c9ba8a1e36..412078c07a 100644 --- a/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql +++ b/backend/services/case-management/src/test/resources/dml/init_review_functional_case_test.sql @@ -13,7 +13,12 @@ VALUES ('gyq_case_id_4', 106, 'TEST_MODULE_ID', 'wx_test_project', '100001', ' INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) VALUES ('gyq_case_id_5', 102, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_4', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), ('gyq_case_id_7', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_7', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), - ('gyq_case_id_8', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_8', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL); + ('gyq_case_id_8', 102, 'TEST_MODULE_ID_COUNT_three', 'wx_test_project', '100001', '测试模块2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_8', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), + ('gyq_case_id_9', 104, 'TEST_MODULE_ID_COUNT_four', 'wx_test_project_review_two', '100001', '测试模块2-1', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_9', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), + ('gyq_case_id_a', 105, 'TEST_MODULE_ID_COUNT_five', 'wx_test_project_review_two', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), + ('gyq_case_id_b', 105, 'TEST_MODULE_ID_COUNT_six', 'wx_test_project_review_one', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL), + ('gyq_case_id_c', 105, 'TEST_MODULE_ID_COUNT_seven', 'wx_test_project_review_one', '100001', '测试模块2-2', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'gyq_case_id_a', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL); + INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, review_status, tags, case_edit_type, pos, version_id, ref_id, last_execute_result, deleted, public_case, latest, create_user, update_user, delete_user, create_time, update_time, delete_time) VALUES ('wx_case_id_3', 104, 'TEST_MODULE_ID', 'wx_test_project', '100001', '测试多版本', 'UN_REVIEWED', '["测试标签_1"]', 'STEP', 0, 'v1.0.0', 'TEST_REF_ID', 'UN_EXECUTED', b'0', b'0', b'1', 'admin', 'admin', '', 1698058347559, 1698058347559, NULL); @@ -51,7 +56,11 @@ VALUES ('wx_test_1', 'wx_review_id_1', 'wx_case_id_1', 'PASS', 1698058347559,'ad ('gyq_test_5', 'wx_review_id_1', 'gyq_case_id_5', 'PASS', 1698058347559,'admin',1698058347559, 2000), ('gyq_test_7', 'wx_review_id_1', 'gyq_case_id_7', 'PASS', 1698058347559,'admin',1698058347559, 2000), ('gyq_test_8', 'wx_review_id_1', 'gyq_case_id_8', 'PASS', 1698058347559,'admin',1698058347559, 2000), - ('wx_test_2', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000), + ('gyq_test_9', 'wx_review_id_2', 'gyq_case_id_9', 'PASS', 1698058347559,'admin',1698058347559, 2000), + ('gyq_test_a', 'wx_review_id_2', 'gyq_case_id_a', 'PASS', 1698058347559,'admin',1698058347559, 2000), + ('gyq_test_b', 'wx_review_id_2', 'gyq_case_id_b', 'PASS', 1698058347559,'admin',1698058347559, 2000), + ('gyq_test_c', 'wx_review_id_2', 'gyq_case_id_c', 'PASS', 1698058347559,'admin',1698058347559, 2000), + ('wx_test_2', 'wx_review_id_2', 'wx_case_id_3', 'PASS', 1698058347559,'admin',1698058347559, 3000), ('wx_test_3', 'wx_review_id_2', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000), ('wx_test_4', 'wx_review_id_2', 'wx_case_id_2', 'PASS', 1698058347559,'admin',1698058347559, 3000), ('wx_test_5', 'wx_review_id_3', 'wx_case_id_1', 'PASS', 1698058347559,'admin',1698058347559, 3000), @@ -83,8 +92,17 @@ INSERT INTO case_review_module(id, project_id, name, parent_id, pos, create_time INSERT INTO functional_case_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user) VALUES ('TEST_MODULE_ID', 'wx_test_project', '测试所属模块', 'NONE', 1568, 1669174143999, 1669174143999, 'admin', 'admin'), ('TEST_MODULE_ID_COUNT_ID', 'wx_test_project', '测试所属模块子集', 'TEST_MODULE_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'), - ('TEST_MODULE_ID_COUNT_three', 'wx_test_project', '测试所属模块子集2', 'TEST_MODULE_ID_COUNT_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'); + ('TEST_MODULE_ID_COUNT_three', 'wx_test_project', '测试所属模块子集2', 'TEST_MODULE_ID_COUNT_ID', 64, 1669174143999, 1669174143999, 'admin', 'admin'), + ('TEST_MODULE_ID_COUNT_six', 'wx_test_project_review_one', '测试多项目模块3', 'NONE', 8, 1669174143999, 1669174143999, 'admin', 'admin'), + ('TEST_MODULE_ID_COUNT_seven', 'wx_test_project_review_one', '测试多项目模块4', 'TEST_MODULE_ID_COUNT_six', 16, 1669174143999, 1669174143999, 'admin', 'admin'), + ('TEST_MODULE_ID_COUNT_four', 'wx_test_project_review_two', '测试多项目模块', 'NONE', 56, 1669174143999, 1669174143999, 'admin', 'admin'), +('TEST_MODULE_ID_COUNT_five', 'wx_test_project_review_two', '测试多项目模块2', 'TEST_MODULE_ID_COUNT_four', 48, 1669174143999, 1669174143999, 'admin', 'admin'); +INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) +VALUES ('wx_test_project_review_one', null, 'organization-associate-case-test', '评审跨项目关联用例', '系统默认创建的项目', + 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000), + ('wx_test_project_review_two', null, 'organization-associate-case-test', '评审跨项目关联用例2', '系统默认创建的项目', + 'admin', 'admin', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000); INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseTreeNode.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseTreeNode.java index 1441dae791..a6b44bc64a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseTreeNode.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/BaseTreeNode.java @@ -59,6 +59,7 @@ public class BaseTreeNode { } public void addChild(BaseTreeNode node) { + node.setParentId(this.getId()); children.add(node); }