diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java index 19c2cd2278..fbdcb3bb1e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/CaseReviewDTO.java @@ -33,4 +33,10 @@ public class CaseReviewDTO extends CaseReview { @Schema(description = "所属模块名称") private String moduleName; + @Schema(description = "创建人名称") + private String createUserName; + + @Schema(description = "更新人名称") + private String updateUserName; + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCasePageDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCasePageDTO.java index 298aa7a142..7989db70c6 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCasePageDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCasePageDTO.java @@ -14,4 +14,18 @@ public class FunctionalCasePageDTO extends FunctionalCase { @Schema(description = "自定义字段集合") private List customFields; + + @Schema(description = "版本名称") + private String versionName; + + @Schema(description = "创建人名称") + private String createUserName; + + @Schema(description = "更新人名称") + private String updateUserName; + + @Schema(description = "删除人名称") + private String deleteUserName; + + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewFunctionalCaseDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewFunctionalCaseDTO.java index 906366993d..e8afd3624d 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewFunctionalCaseDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewFunctionalCaseDTO.java @@ -55,4 +55,7 @@ public class ReviewFunctionalCaseDTO implements Serializable { @Schema(description = "用例创建人") private String createUser; + @Schema(description = "用例创建人名称") + private String createUserName; + } 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 4fdc6be9b2..f44220ae5a 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 @@ -36,6 +36,7 @@ crfc.`status` as status, crfc.create_time as createTime, crfc.create_user as createUser, + user.name as createUserName, functional_case.version_id as versionId, functional_case.module_id as moduleId, functional_case.name as name, @@ -44,6 +45,7 @@ FROM case_review_functional_case crfc LEFT JOIN functional_case ON crfc.case_id = functional_case.id + LEFT JOIN user ON crfc.create_user = user.id WHERE review_id = #{request.reviewId} AND functional_case.deleted = #{deleted} diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml index 76c440a8f5..9bcc545d2f 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/mapper/ExtFunctionalCaseMapper.xml @@ -100,22 +100,24 @@ 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 c4a1e62e1e..ad7596fc81 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 @@ -20,6 +20,7 @@ import io.metersphere.sdk.util.BeanUtils; import io.metersphere.system.dto.sdk.request.PosRequest; import io.metersphere.system.dto.user.UserDTO; import io.metersphere.system.mapper.ExtUserMapper; +import io.metersphere.system.service.UserLoginService; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.NumGenerator; import io.metersphere.system.utils.ServiceUtils; @@ -33,11 +34,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 用例评审表服务实现类 @@ -80,6 +79,8 @@ public class CaseReviewService { private BaseCaseProvider provider; @Resource private ExtCaseReviewHistoryMapper extCaseReviewHistoryMapper; + @Resource + private UserLoginService userLoginService; private static final String CASE_MODULE_COUNT_ALL = "all"; @@ -98,13 +99,23 @@ public class CaseReviewService { List reviewIds = list.stream().map(CaseReview::getId).toList(); Map> reviewCaseMap = getReviewCaseMap(reviewIds); List reviewUsers = getReviewUsers(reviewIds); + Set userIds = extractUserIds(list); + Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); for (CaseReviewDTO caseReviewDTO : list) { buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers); + caseReviewDTO.setCreateUserName(userMap.get(caseReviewDTO.getCreateUser())); + caseReviewDTO.setUpdateUserName(userMap.get(caseReviewDTO.getUpdateUser())); } return list; } + private Set extractUserIds(List list) { + return list.stream() + .flatMap(caseReviewDTO -> Stream.of(caseReviewDTO.getUpdateUser(), caseReviewDTO.getCreateUser())) + .collect(Collectors.toSet()); + } + /** * 通过 reviewCaseMap reviewUserMap 补充 用例评审的其他属性 * @@ -599,7 +610,7 @@ public class CaseReviewService { } public String getReviewPassRule(String id) { - return extCaseReviewMapper.getReviewPassRule(id); + return extCaseReviewMapper.getReviewPassRule(id); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index acea71be26..55e6936ea6 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -44,6 +44,7 @@ import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.sender.AfterReturningNoticeSendService; import io.metersphere.system.service.BaseCustomFieldOptionService; import io.metersphere.system.service.BaseCustomFieldService; +import io.metersphere.system.service.UserLoginService; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.NumGenerator; import io.metersphere.system.utils.ServiceUtils; @@ -62,6 +63,7 @@ import org.springframework.web.multipart.MultipartFile; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author wx @@ -113,6 +115,9 @@ public class FunctionalCaseService { @Resource private BaseCaseProvider provider; + @Resource + private UserLoginService userLoginService; + private static final String CASE_MODULE_COUNT_ALL = "all"; private static final String ADD_FUNCTIONAL_CASE_FILE_LOG_URL = "/functional/case/add"; @@ -545,13 +550,24 @@ public class FunctionalCaseService { private List handleCustomFields(List functionalCaseLists) { List ids = functionalCaseLists.stream().map(FunctionalCasePageDTO::getId).collect(Collectors.toList()); Map> collect = getCaseCustomFiledMap(ids); + Set userIds = extractUserIds(functionalCaseLists); + Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); functionalCaseLists.forEach(functionalCasePageDTO -> { functionalCasePageDTO.setCustomFields(collect.get(functionalCasePageDTO.getId())); + functionalCasePageDTO.setCreateUserName(userMap.get(functionalCasePageDTO.getCreateUser())); + functionalCasePageDTO.setUpdateUserName(userMap.get(functionalCasePageDTO.getUpdateUser())); + functionalCasePageDTO.setDeleteUserName(userMap.get(functionalCasePageDTO.getDeleteUserName())); }); return functionalCaseLists; } + private Set extractUserIds(List list) { + return list.stream() + .flatMap(functionalCasePageDTO -> Stream.of(functionalCasePageDTO.getUpdateUser(), functionalCasePageDTO.getDeleteUser(), functionalCasePageDTO.getCreateUser())) + .collect(Collectors.toSet()); + } + public Map> getCaseCustomFiledMap(List ids) { List customFields = functionalCaseCustomFieldService.getCustomFieldsByCaseIds(ids); customFields.forEach(customField -> {