From 635b851f3bf9ffa084ef81d1390a193ac0cf7d5e Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 20 Feb 2024 13:39:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=AF=84=E5=AE=A1=E4=BA=BA=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1035807 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035807 --- .../functional/service/CaseReviewService.java | 14 ++++++++------ .../controller/CaseReviewControllerTests.java | 7 ------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java index 6df7798234..f8508f056e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewService.java @@ -100,8 +100,9 @@ public class CaseReviewService { List reviewUsers = getReviewUsers(reviewIds); Set userIds = extractUserIds(list); Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); + Map> reviewUserMap = reviewUsers.stream().collect(Collectors.groupingBy(CaseReviewUserDTO::getReviewId)); for (CaseReviewDTO caseReviewDTO : list) { - buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers); + buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUserMap); caseReviewDTO.setCreateUserName(userMap.get(caseReviewDTO.getCreateUser())); caseReviewDTO.setUpdateUserName(userMap.get(caseReviewDTO.getUpdateUser())); } @@ -121,7 +122,7 @@ public class CaseReviewService { * @param caseReviewDTO caseReviewDTO * @param reviewCaseMap 用例和评审的关系map */ - private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map> reviewCaseMap, List reviewUsers) { + private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map> reviewCaseMap, Map> reviewUserMap) { String caseReviewId = caseReviewDTO.getId(); List caseReviewFunctionalCaseList = reviewCaseMap.get(caseReviewId); if (CollectionUtils.isEmpty(caseReviewFunctionalCaseList)) { @@ -133,7 +134,7 @@ public class CaseReviewService { } else { buildAboutCaseCount(caseReviewDTO, caseReviewFunctionalCaseList); } - caseReviewDTO.setReviewers(reviewUsers); + caseReviewDTO.setReviewers(reviewUserMap.get(caseReviewId)); } @@ -536,7 +537,9 @@ public class CaseReviewService { caseReviewDTO.setFollowFlag(isFollow); Map> reviewCaseMap = getReviewCaseMap(List.of(id)); List reviewUsers = getReviewUsers(List.of(id)); - buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers); + Map> reviewUsersMap = new HashMap<>(); + reviewUsersMap.put(id, reviewUsers); + buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsersMap); return caseReviewDTO; } @@ -576,7 +579,6 @@ public class CaseReviewService { } public void disassociate(String reviewId, String caseId, String userId) { - checkCaseReview(reviewId); checkCase(caseId); //1.刪除评审与功能用例关联关系 CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); @@ -613,5 +615,5 @@ public class CaseReviewService { return extCaseReviewMapper.getReviewPassRule(id); } - + } \ No newline at end of file diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java index 09b2d4f3d5..e3e4901b2b 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewControllerTests.java @@ -598,13 +598,6 @@ public class CaseReviewControllerTests extends BaseTest { @Order(18) public void testDisassociateFalse() throws Exception { List caseReviews = getCaseReviews("创建评审更新1"); - mockMvc.perform(MockMvcRequestBuilders.get(DISASSOCIATE_CASE_REVIEW+"caseReviewIdX"+"/CASE_REVIEW_TEST_GYQ_ID6").header(SessionConstants.HEADER_TOKEN, sessionId) - .header(SessionConstants.CSRF_TOKEN, csrfToken) - .header(SessionConstants.CURRENT_PROJECT, projectId) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is5xxServerError()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); - String caseReviewId = caseReviews.get(0).getId(); mockMvc.perform(MockMvcRequestBuilders.get(DISASSOCIATE_CASE_REVIEW+caseReviewId+"/CASE_REVIEW_TEST_GYQ_IDXX").header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken)