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 faa2208d60..45d163b798 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 @@ -10,6 +10,7 @@ import io.metersphere.functional.service.CaseReviewFunctionalCaseService; import io.metersphere.functional.service.CaseReviewLogService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.security.CheckOwner; @@ -17,6 +18,7 @@ import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.shiro.authz.annotation.RequiresPermissions; @@ -112,4 +114,15 @@ public class CaseReviewFunctionalCaseController { caseReviewFunctionalCaseService.batchEditReviewUser(request, SessionUtils.getUserId()); } + @GetMapping("/reviewer/status/{reviewId}/{caseId}") + @Operation(summary = "用例管理-用例评审-评审列表-评审详情-评审结果的气泡数据") + @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) + @CheckOwner(resourceId = "#projectId", resourceType = "project") + public List getUserStatus(@Schema(description = "评审id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("reviewId") String reviewId, @Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("caseId") String caseId) { + return caseReviewFunctionalCaseService.getUserStatus(reviewId, caseId); + } + + } 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 2da4985de5..f531f12b26 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,6 +6,7 @@ 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.mapper.*; @@ -22,6 +23,7 @@ import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.utils.ServiceUtils; @@ -80,6 +82,8 @@ public class CaseReviewFunctionalCaseService { private FunctionalCaseAttachmentService functionalCaseAttachmentService; @Resource private FunctionalCaseModuleService functionalCaseModuleService; + @Resource + private ExtCaseReviewHistoryMapper extCaseReviewHistoryMapper; @@ -575,4 +579,16 @@ public class CaseReviewFunctionalCaseService { return functionalCaseModuleService.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module")); } + public List getUserStatus(String reviewId, String caseId) { + List list = extCaseReviewHistoryMapper.list(caseId, reviewId); + Map> collect = list.stream().sorted(Comparator.comparingLong(CaseReviewHistoryDTO::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistoryDTO::getCreateUser, Collectors.toList())); + ListoptionDTOS = new ArrayList<>(); + collect.forEach((k,v)->{ + OptionDTO optionDTO = new OptionDTO(); + optionDTO.setId(v.get(0).getUserName()); + optionDTO.setName(v.get(0).getStatus()); + optionDTOS.add(optionDTO); + }); + return optionDTOS; + } } \ No newline at end of file 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 b861e93b13..733c66d131 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 @@ -6,7 +6,6 @@ import io.metersphere.functional.domain.CaseReviewFunctionalCase; import io.metersphere.functional.domain.CaseReviewFunctionalCaseExample; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; -import io.metersphere.functional.mapper.CaseReviewFunctionalCaseUserMapper; import io.metersphere.functional.request.*; import io.metersphere.sdk.constants.ModuleConstants; import io.metersphere.sdk.constants.SessionConstants; @@ -15,8 +14,10 @@ import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.dto.sdk.BaseCondition; import io.metersphere.system.dto.sdk.BaseTreeNode; +import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.utils.Pager; import jakarta.annotation.Resource; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.*; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -55,11 +56,12 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { public static final String REVIEW_FUNCTIONAL_CASE_MODULE_COUNT= "/case/review/detail/module/count"; + public static final String REVIEW_FUNCTIONAL_CASE_REVIEWER_STATUS= "/case/review/detail/reviewer/status/"; + + @Resource private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; - @Resource - private CaseReviewFunctionalCaseUserMapper caseReviewFunctionalCaseUserMapper; @Test @Order(1) @@ -145,7 +147,7 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { //检查有没有默认节点 boolean hasNode = false; for (BaseTreeNode baseTreeNode : treeNodes) { - if (org.testcontainers.shaded.org.apache.commons.lang3.StringUtils.equals(baseTreeNode.getId(), ModuleConstants.DEFAULT_NODE_ID)) { + if (StringUtils.equals(baseTreeNode.getId(), ModuleConstants.DEFAULT_NODE_ID)) { hasNode = true; } Assertions.assertNotNull(baseTreeNode.getParentId()); @@ -235,13 +237,6 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { @Test @Order(8) public void testBatchReview() throws Exception { - /*List caseReviewList = getCaseReviewFunctionalCase("wx_review_id_1"); - List list = caseReviewList.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getCreateUser(), "admin")).toList(); - CaseReviewFunctionalCaseUser caseReviewFunctionalCaseUser = new CaseReviewFunctionalCaseUser(); - caseReviewFunctionalCaseUser.setReviewId("wx_review_id_1"); - caseReviewFunctionalCaseUser.setCaseId(list.get(0).getCaseId()); - caseReviewFunctionalCaseUser.setUserId("admin"); - caseReviewFunctionalCaseUserMapper.insertSelective(caseReviewFunctionalCaseUser);*/ BatchReviewFunctionalCaseRequest request = new BatchReviewFunctionalCaseRequest(); request.setReviewId("wx_review_id_1"); @@ -362,6 +357,28 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { this.requestPostWithOkAndReturn(BATCH_EDIT_REVIEWERS, request); } + @Test + @Order(11) + public void getUserStatus() throws Exception { + List optionDTOS = getOptionDTOS("wx_review_id_1","gyq_case_id_5"); + Assertions.assertTrue(CollectionUtils.isNotEmpty(optionDTOS)); + optionDTOS = getOptionDTOS("wx_review_id_1_NONE","gyq_case_id_5"); + Assertions.assertTrue(CollectionUtils.isEmpty(optionDTOS)); + } + + 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) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); + List optionDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), OptionDTO.class); + return optionDTOS; + } + + 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) .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 42b7163071..63dfcbd00f 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 @@ -59,11 +59,12 @@ VALUES ('wx_test_1', 'wx_review_id_1', 'wx_case_id_1', 'PASS', 1698058347559,'ad INSERT INTO case_review_functional_case_user(case_id, review_id, user_id) VALUES ('wx_case_id_1', 'wx_review_id_1', 'admin'), - ('wx_case_id_1', 'wx_review_id_1', 'gyq'), + ('wx_case_id_1', 'wx_review_id_1', 'gyq_case_review'), ('wx_test_1', 'wx_review_id_1', 'admin'), ('gyq_review_case_id_3', 'wx_review_id_1', 'admin'), ('gyq_case_id_4', 'wx_review_id_1', 'admin'), - ('gyq_case_id_5', 'wx_review_id_1', 'gyq'), + ('gyq_case_id_5', 'wx_review_id_1', 'gyq_case_review'), + ('gyq_case_id_5', 'wx_review_id_1', 'GGG'), ('wx_case_id_3', 'wx_review_id_3', 'admin'), ('wx_case_id_4', 'wx_review_id_4', 'admin'), ('wx_case_id_1', 'wx_review_id_4', '123'), @@ -78,11 +79,18 @@ 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', 0, 1669174143999, 1669174143999, 'admin', 'admin'); +INSERT INTO user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, + last_project_id, create_user, update_user, deleted) +VALUES ('gyq_case_review', 'gyq_case_review', 'gyq_case_review_case@fit2cloud.com', MD5('metersphere'),UNIX_TIMESTAMP() * 1000,UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false), + ('GGG', 'GGG', 'GGG_case_review_case@metersphere.io', MD5('metersphere'), UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin', false); + INSERT INTO case_review_history(id, review_id, case_id, content, status, deleted, notifier, create_user, create_time) VALUES ('wx_history', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_histor_1', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_history_2', 'wx_review_id_3', 'wx_case_id_3', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), ('wx_history_3', 'wx_review_id_4', 'wx_case_id_4', NULL, 'PASS', b'0', NULL, 'A', 1669174143999), ('wx_history_4', 'wx_review_id_4', 'wx_case_id_1', NULL, 'PASS', b'0', NULL, 'admin', 1669174143999), - ('wx_history_5', 'wx_review_id_4', 'wx_case_id_2', NULL, 'UN_PASS', b'0', NULL, 'admin', 1669174143999); + ('wx_history_5', 'wx_review_id_4', 'wx_case_id_2', NULL, 'UN_PASS', b'0', NULL, 'admin', 1669174143999), + ('wx_history_6', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'PASS', b'0', NULL, 'gyq_case_review', 1669174143999), + ('wx_history_7', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'UN_PASS', b'0', NULL, 'GGG', 1669174143999);