fix(用例管理): 修复用例评审列表评审人显示问题

--bug=1035807 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035807
This commit is contained in:
guoyuqi 2024-02-20 13:39:22 +08:00 committed by 刘瑞斌
parent 316310716b
commit 635b851f3b
2 changed files with 8 additions and 13 deletions

View File

@ -100,8 +100,9 @@ public class CaseReviewService {
List<CaseReviewUserDTO> reviewUsers = getReviewUsers(reviewIds); List<CaseReviewUserDTO> reviewUsers = getReviewUsers(reviewIds);
Set<String> userIds = extractUserIds(list); Set<String> userIds = extractUserIds(list);
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds));
Map<String, List<CaseReviewUserDTO>> reviewUserMap = reviewUsers.stream().collect(Collectors.groupingBy(CaseReviewUserDTO::getReviewId));
for (CaseReviewDTO caseReviewDTO : list) { for (CaseReviewDTO caseReviewDTO : list) {
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers); buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUserMap);
caseReviewDTO.setCreateUserName(userMap.get(caseReviewDTO.getCreateUser())); caseReviewDTO.setCreateUserName(userMap.get(caseReviewDTO.getCreateUser()));
caseReviewDTO.setUpdateUserName(userMap.get(caseReviewDTO.getUpdateUser())); caseReviewDTO.setUpdateUserName(userMap.get(caseReviewDTO.getUpdateUser()));
} }
@ -121,7 +122,7 @@ public class CaseReviewService {
* @param caseReviewDTO caseReviewDTO * @param caseReviewDTO caseReviewDTO
* @param reviewCaseMap 用例和评审的关系map * @param reviewCaseMap 用例和评审的关系map
*/ */
private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap, List<CaseReviewUserDTO> reviewUsers) { private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap, Map<String, List<CaseReviewUserDTO>> reviewUserMap) {
String caseReviewId = caseReviewDTO.getId(); String caseReviewId = caseReviewDTO.getId();
List<CaseReviewFunctionalCase> caseReviewFunctionalCaseList = reviewCaseMap.get(caseReviewId); List<CaseReviewFunctionalCase> caseReviewFunctionalCaseList = reviewCaseMap.get(caseReviewId);
if (CollectionUtils.isEmpty(caseReviewFunctionalCaseList)) { if (CollectionUtils.isEmpty(caseReviewFunctionalCaseList)) {
@ -133,7 +134,7 @@ public class CaseReviewService {
} else { } else {
buildAboutCaseCount(caseReviewDTO, caseReviewFunctionalCaseList); buildAboutCaseCount(caseReviewDTO, caseReviewFunctionalCaseList);
} }
caseReviewDTO.setReviewers(reviewUsers); caseReviewDTO.setReviewers(reviewUserMap.get(caseReviewId));
} }
@ -536,7 +537,9 @@ public class CaseReviewService {
caseReviewDTO.setFollowFlag(isFollow); caseReviewDTO.setFollowFlag(isFollow);
Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap = getReviewCaseMap(List.of(id)); Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap = getReviewCaseMap(List.of(id));
List<CaseReviewUserDTO> reviewUsers = getReviewUsers(List.of(id)); List<CaseReviewUserDTO> reviewUsers = getReviewUsers(List.of(id));
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers); Map<String, List<CaseReviewUserDTO>> reviewUsersMap = new HashMap<>();
reviewUsersMap.put(id, reviewUsers);
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsersMap);
return caseReviewDTO; return caseReviewDTO;
} }
@ -576,7 +579,6 @@ public class CaseReviewService {
} }
public void disassociate(String reviewId, String caseId, String userId) { public void disassociate(String reviewId, String caseId, String userId) {
checkCaseReview(reviewId);
checkCase(caseId); checkCase(caseId);
//1.刪除评审与功能用例关联关系 //1.刪除评审与功能用例关联关系
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();

View File

@ -598,13 +598,6 @@ public class CaseReviewControllerTests extends BaseTest {
@Order(18) @Order(18)
public void testDisassociateFalse() throws Exception { public void testDisassociateFalse() throws Exception {
List<CaseReview> caseReviews = getCaseReviews("创建评审更新1"); List<CaseReview> 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(); String caseReviewId = caseReviews.get(0).getId();
mockMvc.perform(MockMvcRequestBuilders.get(DISASSOCIATE_CASE_REVIEW+caseReviewId+"/CASE_REVIEW_TEST_GYQ_IDXX").header(SessionConstants.HEADER_TOKEN, sessionId) mockMvc.perform(MockMvcRequestBuilders.get(DISASSOCIATE_CASE_REVIEW+caseReviewId+"/CASE_REVIEW_TEST_GYQ_IDXX").header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CSRF_TOKEN, csrfToken)