fix(用例管理): 功能用例和用例评审显示版本和操作人名称
This commit is contained in:
parent
e46f19cc70
commit
6afb32e22e
|
@ -33,4 +33,10 @@ public class CaseReviewDTO extends CaseReview {
|
|||
@Schema(description = "所属模块名称")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "创建人名称")
|
||||
private String createUserName;
|
||||
|
||||
@Schema(description = "更新人名称")
|
||||
private String updateUserName;
|
||||
|
||||
}
|
||||
|
|
|
@ -14,4 +14,18 @@ public class FunctionalCasePageDTO extends FunctionalCase {
|
|||
|
||||
@Schema(description = "自定义字段集合")
|
||||
private List<FunctionalCaseCustomFieldDTO> customFields;
|
||||
|
||||
@Schema(description = "版本名称")
|
||||
private String versionName;
|
||||
|
||||
@Schema(description = "创建人名称")
|
||||
private String createUserName;
|
||||
|
||||
@Schema(description = "更新人名称")
|
||||
private String updateUserName;
|
||||
|
||||
@Schema(description = "删除人名称")
|
||||
private String deleteUserName;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,7 @@ public class ReviewFunctionalCaseDTO implements Serializable {
|
|||
@Schema(description = "用例创建人")
|
||||
private String createUser;
|
||||
|
||||
@Schema(description = "用例创建人名称")
|
||||
private String createUserName;
|
||||
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -100,22 +100,24 @@
|
|||
|
||||
<select id="list" resultMap="BaseResultMapDTO">
|
||||
SELECT
|
||||
id,
|
||||
num,
|
||||
NAME,
|
||||
module_id,
|
||||
version_id,
|
||||
case_edit_type,
|
||||
create_user,
|
||||
create_time,
|
||||
update_user,
|
||||
update_time,
|
||||
review_status,
|
||||
last_execute_result,
|
||||
tags
|
||||
functional_case.id,
|
||||
functional_case.num,
|
||||
functional_case.NAME,
|
||||
functional_case.module_id,
|
||||
functional_case.version_id,
|
||||
project_version.name as versionName,
|
||||
functional_case.case_edit_type,
|
||||
functional_case.create_user,
|
||||
functional_case.create_time,
|
||||
functional_case.update_user,
|
||||
functional_case.update_time,
|
||||
functional_case.review_status,
|
||||
functional_case.last_execute_result,
|
||||
functional_case.tags
|
||||
FROM
|
||||
functional_case
|
||||
where deleted = #{deleted}
|
||||
LEFT JOIN project_version ON functional_case.version_id = project_version.id
|
||||
where functional_case.deleted = #{deleted}
|
||||
and functional_case.project_id = #{request.projectId}
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
|
@ -129,7 +131,7 @@
|
|||
</choose>
|
||||
<if test="request.reviewId != null and request.reviewId != ''">
|
||||
AND functional_case.id not in (
|
||||
select case_id from case_review_functional_case where review_id = #{request.reviewId}
|
||||
select case_review_functional_case.case_id from case_review_functional_case where case_review_functional_case.review_id = #{request.reviewId}
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
|
|
@ -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<String> reviewIds = list.stream().map(CaseReview::getId).toList();
|
||||
Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap = getReviewCaseMap(reviewIds);
|
||||
List<CaseReviewUserDTO> reviewUsers = getReviewUsers(reviewIds);
|
||||
Set<String> userIds = extractUserIds(list);
|
||||
Map<String, String> 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<String> extractUserIds(List<CaseReviewDTO> 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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<FunctionalCasePageDTO> handleCustomFields(List<FunctionalCasePageDTO> functionalCaseLists) {
|
||||
List<String> ids = functionalCaseLists.stream().map(FunctionalCasePageDTO::getId).collect(Collectors.toList());
|
||||
Map<String, List<FunctionalCaseCustomFieldDTO>> collect = getCaseCustomFiledMap(ids);
|
||||
Set<String> userIds = extractUserIds(functionalCaseLists);
|
||||
Map<String, String> 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<String> extractUserIds(List<FunctionalCasePageDTO> list) {
|
||||
return list.stream()
|
||||
.flatMap(functionalCasePageDTO -> Stream.of(functionalCasePageDTO.getUpdateUser(), functionalCasePageDTO.getDeleteUser(), functionalCasePageDTO.getCreateUser()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Map<String, List<FunctionalCaseCustomFieldDTO>> getCaseCustomFiledMap(List<String> ids) {
|
||||
List<FunctionalCaseCustomFieldDTO> customFields = functionalCaseCustomFieldService.getCustomFieldsByCaseIds(ids);
|
||||
customFields.forEach(customField -> {
|
||||
|
|
Loading…
Reference in New Issue