fix(功能用例): 修复接口连调发现的问题
This commit is contained in:
parent
276ac224f2
commit
0ef5e7a6bf
|
@ -74,8 +74,8 @@ public class CaseReviewController {
|
|||
@SendNotice(taskType = NoticeConstants.TaskType.CASE_REVIEW_TASK, event = NoticeConstants.Event.CREATE, target = "#targetClass.getMainCaseReview(#request)", targetClass = CaseReviewNoticeService.class)
|
||||
@RequiresPermissions(PermissionConstants.CASE_REVIEW_READ_ADD)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public void copyCaseReview(@Validated @RequestBody CaseReviewRequest request) {
|
||||
caseReviewService.addCaseReview(request, SessionUtils.getUserId());
|
||||
public String copyCaseReview(@Validated @RequestBody CaseReviewCopyRequest request) {
|
||||
return caseReviewService.copyCaseReview(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
public class CaseReviewDTO extends CaseReview {
|
||||
|
||||
@Schema(description = "评审人")
|
||||
private List<String> reviewers;
|
||||
private List<CaseReviewUserDTO> reviewers;
|
||||
|
||||
@Schema(description = "通过数")
|
||||
private int passCount;
|
||||
|
@ -29,4 +29,8 @@ public class CaseReviewDTO extends CaseReview {
|
|||
|
||||
@Schema(description = "关注标识")
|
||||
private Boolean followFlag;
|
||||
|
||||
@Schema(description = "所属模块名称")
|
||||
private String moduleName;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,4 +9,7 @@ public class CaseReviewUserDTO extends CaseReviewUser {
|
|||
|
||||
@Schema(description = "用户名")
|
||||
private String userName;
|
||||
|
||||
@Schema(description = "头像")
|
||||
private String avatar;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class FunctionalCaseReviewDTO extends CaseReviewFunctionalCase {
|
|||
@NotBlank(message = "{case_review_functional_case.review_name.not_blank}")
|
||||
private String reviewName;
|
||||
|
||||
@Schema(description = "用例评审状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "用例评审状态:未开始(PREPARED)/进行中(UNDERWAY)/已完成(COMPLETED)/已归档(ARCHIVED)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{case_review_functional_case.review_status.not_blank}")
|
||||
private String reviewStatus;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<select id="list" resultType="io.metersphere.functional.dto.FunctionalCaseReviewDTO">
|
||||
SELECT
|
||||
cr.num as reviewNum, cr.name as reviewName, cr.status as reviewStatus, cf.status, cf.update_time
|
||||
cf.*, cr.num as reviewNum, cr.name as reviewName, cr.status as reviewStatus
|
||||
FROM
|
||||
case_review_functional_case cf left join case_review cr on cf.review_id = cr.id
|
||||
where cf.case_id = #{request.caseId}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
<select id="list" resultType="io.metersphere.functional.dto.CaseReviewDTO">
|
||||
SELECT
|
||||
*
|
||||
case_review.* , case_review_module.name as moduleName
|
||||
FROM
|
||||
case_review
|
||||
case_review left join case_review_module on case_review.module_id = case_review_module.id
|
||||
where case_review.project_id = #{request.projectId}
|
||||
<choose>
|
||||
<when test='request.searchMode == "AND"'>
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
<select id="getReviewUser" resultType="io.metersphere.functional.dto.CaseReviewUserDTO">
|
||||
SELECT
|
||||
cu.user_id ,cu.review_id, u.name as userName
|
||||
cu.user_id ,cu.review_id, u.name as userName, ue.avatar as avatar
|
||||
FROM
|
||||
case_review_user cu left join user u on cu.user_id = u.id
|
||||
left join user_extend ue on cu.user_id = ue.id
|
||||
WHERE
|
||||
cu.review_id in
|
||||
<foreach collection="reviewIds" item="id" open="(" separator="," close=")">
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.functional.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CaseReviewCopyRequest extends CaseReviewRequest{
|
||||
|
||||
@Schema(description = "被复制的用例评审id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{case_review_copy_request.copy_id.not_blank}")
|
||||
private String copyId;
|
||||
}
|
|
@ -97,9 +97,9 @@ public class CaseReviewService {
|
|||
}
|
||||
List<String> reviewIds = list.stream().map(CaseReview::getId).toList();
|
||||
Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap = getReviewCaseMap(reviewIds);
|
||||
Map<String, List<CaseReviewUserDTO>> reviewUserMap = getReviewUserMap(reviewIds);
|
||||
List<CaseReviewUserDTO> reviewUsers = getReviewUsers(reviewIds);
|
||||
for (CaseReviewDTO caseReviewDTO : list) {
|
||||
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUserMap);
|
||||
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -110,9 +110,8 @@ public class CaseReviewService {
|
|||
*
|
||||
* @param caseReviewDTO caseReviewDTO
|
||||
* @param reviewCaseMap 用例和评审的关系map
|
||||
* @param reviewUserMap 评审和评审人的关系map
|
||||
*/
|
||||
private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap, Map<String, List<CaseReviewUserDTO>> reviewUserMap) {
|
||||
private static void buildCaseReviewDTO(CaseReviewDTO caseReviewDTO, Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap, List<CaseReviewUserDTO> reviewUsers) {
|
||||
String caseReviewId = caseReviewDTO.getId();
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCaseList = reviewCaseMap.get(caseReviewId);
|
||||
if (CollectionUtils.isEmpty(caseReviewFunctionalCaseList)) {
|
||||
|
@ -124,15 +123,9 @@ public class CaseReviewService {
|
|||
} else {
|
||||
buildAboutCaseCount(caseReviewDTO, caseReviewFunctionalCaseList);
|
||||
}
|
||||
|
||||
buildReviewers(caseReviewDTO, reviewUserMap);
|
||||
caseReviewDTO.setReviewers(reviewUsers);
|
||||
}
|
||||
|
||||
private static void buildReviewers(CaseReviewDTO caseReviewDTO, Map<String, List<CaseReviewUserDTO>> reviewUserMap) {
|
||||
List<CaseReviewUserDTO> caseReviewUserDTOS = reviewUserMap.get(caseReviewDTO.getId());
|
||||
List<String> userNames = caseReviewUserDTOS.stream().map(CaseReviewUserDTO::getUserName).toList();
|
||||
caseReviewDTO.setReviewers(userNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建用例相关的各种数量
|
||||
|
@ -176,9 +169,8 @@ public class CaseReviewService {
|
|||
* @param reviewIds 评审ids
|
||||
* @return Map
|
||||
*/
|
||||
private Map<String, List<CaseReviewUserDTO>> getReviewUserMap(List<String> reviewIds) {
|
||||
List<CaseReviewUserDTO> reviewUser = extCaseReviewUserMapper.getReviewUser(reviewIds);
|
||||
return reviewUser.stream().collect(Collectors.groupingBy(CaseReviewUserDTO::getReviewId));
|
||||
private List<CaseReviewUserDTO> getReviewUsers(List<String> reviewIds) {
|
||||
return extCaseReviewUserMapper.getReviewUser(reviewIds);
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,6 +197,11 @@ public class CaseReviewService {
|
|||
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
|
||||
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
|
||||
addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
addAssociate(request, userId, caseReviewId, caseIds);
|
||||
return caseReviewId;
|
||||
}
|
||||
|
||||
private void addAssociate(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class);
|
||||
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
|
||||
|
@ -220,6 +217,16 @@ public class CaseReviewService {
|
|||
} finally {
|
||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
public String copyCaseReview(CaseReviewCopyRequest request, String userId) {
|
||||
String caseReviewId = IDGenerator.nextStr();
|
||||
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(request.getCopyId());
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).distinct().toList();
|
||||
addCaseReview(request, userId, caseReviewId, caseIds);
|
||||
addAssociate(request, userId, caseReviewId, caseIds);
|
||||
return caseReviewId;
|
||||
}
|
||||
|
||||
|
@ -262,6 +269,7 @@ public class CaseReviewService {
|
|||
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
||||
caseReview.setTags(request.getTags());
|
||||
}
|
||||
caseReview.setDescription(request.getDescription());
|
||||
caseReview.setStartTime(request.getStartTime());
|
||||
caseReview.setEndTime(request.getEndTime());
|
||||
caseReview.setUpdateTime(System.currentTimeMillis());
|
||||
|
@ -340,6 +348,7 @@ public class CaseReviewService {
|
|||
} else {
|
||||
caseReview.setCaseCount(caseIds.size());
|
||||
}
|
||||
caseReview.setDescription(request.getDescription());
|
||||
caseReview.setStartTime(request.getStartTime());
|
||||
caseReview.setEndTime(request.getEndTime());
|
||||
caseReview.setCreateTime(System.currentTimeMillis());
|
||||
|
@ -516,8 +525,8 @@ public class CaseReviewService {
|
|||
Boolean isFollow = checkFollow(id, userId);
|
||||
caseReviewDTO.setFollowFlag(isFollow);
|
||||
Map<String, List<CaseReviewFunctionalCase>> reviewCaseMap = getReviewCaseMap(List.of(id));
|
||||
Map<String, List<CaseReviewUserDTO>> reviewUserMap = getReviewUserMap(List.of(id));
|
||||
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUserMap);
|
||||
List<CaseReviewUserDTO> reviewUsers = getReviewUsers(List.of(id));
|
||||
buildCaseReviewDTO(caseReviewDTO, reviewCaseMap, reviewUsers);
|
||||
return caseReviewDTO;
|
||||
}
|
||||
|
||||
|
@ -584,4 +593,6 @@ public class CaseReviewService {
|
|||
public String getReviewPassRule(String id) {
|
||||
return extCaseReviewMapper.getReviewPassRule(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -93,8 +93,9 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
Assertions.assertEquals(1, caseReviewFunctionalCases.size());
|
||||
|
||||
|
||||
caseReviewRequest = getCaseReviewAddRequest("创建评审1", CaseReviewPassRule.SINGLE.toString(), "CASE_REVIEW_TEST_GYQ_ID", false, true, null);
|
||||
this.requestPostWithOk(COPY_CASE_REVIEW, caseReviewRequest);
|
||||
CaseReviewCopyRequest caseReviewCopyRequest = getCaseReviewAddRequest("创建评审1", CaseReviewPassRule.SINGLE.toString(), "CASE_REVIEW_TEST_GYQ_ID", false, true, null);
|
||||
caseReviewCopyRequest.setCopyId(caseReviewId);
|
||||
this.requestPostWithOk(COPY_CASE_REVIEW, caseReviewCopyRequest);
|
||||
caseReviews = getCaseReviews("创建评审1");
|
||||
Assertions.assertEquals(2, caseReviews.size());
|
||||
List<String> list = caseReviews.stream().map(CaseReview::getId).distinct().toList();
|
||||
|
@ -109,8 +110,8 @@ public class CaseReviewControllerTests extends BaseTest {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
private static CaseReviewRequest getCaseReviewAddRequest(String name, String reviewPassRule, String caseId, boolean tag, boolean reviewer, String id) {
|
||||
CaseReviewRequest caseReviewRequest = new CaseReviewRequest();
|
||||
private static CaseReviewCopyRequest getCaseReviewAddRequest(String name, String reviewPassRule, String caseId, boolean tag, boolean reviewer, String id) {
|
||||
CaseReviewCopyRequest caseReviewRequest = new CaseReviewCopyRequest();
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
caseReviewRequest.setId(id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue