diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseTrashController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseTrashController.java index c5e14d05c6..cf87ca311c 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseTrashController.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/FunctionalCaseTrashController.java @@ -47,7 +47,7 @@ public class FunctionalCaseTrashController { } @PostMapping("/module/count") - @Operation(summary = "用例管理-功能用例-回收站-表格分页查询文件") + @Operation(summary = "用例管理-功能用例-回收站-模块树统计用例数量") @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ) @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") public Map moduleCount(@Validated @RequestBody FunctionalCasePageRequest request) { 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 e0f7e87f80..50a512eea1 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 @@ -31,5 +31,5 @@ public interface ExtFunctionalCaseModuleMapper { List selectApiScenarioModuleByRequest(@Param("request") AssociateCaseModuleRequest request); - List selectIdAndParentIdByProjectIdAndReviewId(@Param("projectId")String projectId, @Param("reviewId")String reviewId); + List selectIdByProjectIdAndReviewId(@Param("projectId")String projectId, @Param("reviewId")String reviewId); } 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 b3b4b0b5ee..c97b0683e3 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 @@ -94,8 +94,8 @@ ORDER BY pos - + SELECT fcm.id FROM functional_case_module fcm WHERE fcm.project_id = #{projectId} AND fcm.id IN 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 f531f12b26..d43889044e 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 @@ -575,8 +575,9 @@ public class CaseReviewFunctionalCaseService { public List getTreeOnlyIdsAndResourceCount(String projectId, String reviewId, List moduleCountDTOList) { //节点内容只有Id和parentId - List fileModuleList = extFunctionalCaseModuleMapper.selectIdAndParentIdByProjectIdAndReviewId(projectId, reviewId); - return functionalCaseModuleService.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module")); + List moduleIds = extFunctionalCaseModuleMapper.selectIdByProjectIdAndReviewId(projectId, reviewId); + List nodeByNodeIds = functionalCaseModuleService.getNodeByNodeIds(moduleIds); + return functionalCaseModuleService.buildTreeAndCountResource(nodeByNodeIds, moduleCountDTOList, true, Translator.get("default.module")); } public List getUserStatus(String reviewId, String caseId) { 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 733c66d131..46428d9af8 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 @@ -366,6 +366,24 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { Assertions.assertTrue(CollectionUtils.isEmpty(optionDTOS)); } + @Test + @Order(12) + public void getModuleCount() throws Exception { + ReviewFunctionalCasePageRequest request = new ReviewFunctionalCasePageRequest(); + request.setReviewId("wx_review_id_1"); + request.setCurrent(1); + request.setPageSize(10); + request.setViewFlag(false); + request.setProjectId("wx_test_project"); + MvcResult moduleCountMvcResult = this.requestPostWithOkAndReturn(REVIEW_FUNCTIONAL_CASE_MODULE_COUNT, request); + Map moduleCount = JSON.parseObject(JSON.toJSONString( + JSON.parseObject(moduleCountMvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()), + Map.class); + + Assertions.assertTrue(moduleCount.containsKey("TEST_MODULE_ID_COUNT_three")); + + } + private List getOptionDTOS(String reviewId, String caseId) throws Exception { MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(REVIEW_FUNCTIONAL_CASE_REVIEWER_STATUS+"/"+reviewId+"/"+caseId).header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken) 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 63dfcbd00f..eceb7095a9 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 @@ -11,7 +11,9 @@ INSERT INTO functional_case(id, num, module_id, project_id, template_id, name, r VALUES ('gyq_case_id_4', 106, '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); 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); +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); 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); @@ -47,6 +49,8 @@ VALUES ('wx_test_1', 'wx_review_id_1', 'wx_case_id_1', 'PASS', 1698058347559,'ad ('gyq_test_3', 'wx_review_id_1', 'gyq_review_case_id_3', 'PASS', 1698058347559,'admin',1698058347559, 1500), ('gyq_test_4', 'wx_review_id_1', 'gyq_case_id_4', 'PASS', 1698058347559,'admin',1698058347559, 2000), ('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), ('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), @@ -76,7 +80,11 @@ VALUES ('wx_case_id_1', 'wx_review_id_1', 'admin'), INSERT INTO case_review_module(id, project_id, name, parent_id, pos, create_time, update_time, create_user, update_user) VALUES ('wx_module_1', 'wx_test_project', '测试所属模块', 'NONE', 0, 1669174143999, 1669174143999, 'admin', 'admin'); -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', 0, 1669174143999, 1669174143999, 'admin', 'admin'); +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'); + 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/controller/NotificationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java index dc56b639d1..140847c7e8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/NotificationController.java @@ -46,6 +46,7 @@ public class NotificationController { } @PostMapping(value = "/count") + @Operation(summary = "消息中心-获取消息中心消息具体类型具体状态的数量") public Integer countNotification(@RequestBody Notification notification) { return notificationService.countNotification(notification, SessionUtils.getUserId()); }