fix(用例管理): 尝试修复用例评审创建并关联时,用例评审人和默认评审人不同保存结果相同问题
--bug=1036035 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036035
This commit is contained in:
parent
ea6dce1d7e
commit
acabc30e22
|
@ -3,8 +3,11 @@ package io.metersphere.functional.request;
|
||||||
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
|
import io.metersphere.functional.dto.BaseFunctionalCaseBatchDTO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BaseAssociateCaseRequest extends BaseFunctionalCaseBatchDTO {
|
public class BaseAssociateCaseRequest extends BaseFunctionalCaseBatchDTO {
|
||||||
|
|
||||||
|
@ -12,4 +15,8 @@ public class BaseAssociateCaseRequest extends BaseFunctionalCaseBatchDTO {
|
||||||
@NotBlank(message = "{case_review_associate_request.project_id.not_blank}")
|
@NotBlank(message = "{case_review_associate_request.project_id.not_blank}")
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
|
||||||
|
@Schema(description = "默认评审人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "{case_review.reviewers.not_empty}")
|
||||||
|
private List<String> reviewers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,11 +208,11 @@ public class CaseReviewService {
|
||||||
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
|
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
|
||||||
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
|
List<String> caseIds = doSelectIds(baseAssociateCaseRequest, baseAssociateCaseRequest.getProjectId());
|
||||||
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
||||||
addAssociate(request, userId, caseReviewId, caseIds);
|
addAssociate(request, userId, caseReviewId, caseIds, request.getReviewers());
|
||||||
return caseReview;
|
return caseReview;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAssociate(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds) {
|
private void addAssociate(CaseReviewRequest request, String userId, String caseReviewId, List<String> caseIds, List<String> reviewers) {
|
||||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||||
CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class);
|
CaseReviewUserMapper mapper = sqlSession.getMapper(CaseReviewUserMapper.class);
|
||||||
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
|
CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper = sqlSession.getMapper(CaseReviewFunctionalCaseMapper.class);
|
||||||
|
@ -223,7 +223,7 @@ public class CaseReviewService {
|
||||||
//保存和用例的关系
|
//保存和用例的关系
|
||||||
addCaseReviewFunctionalCase(caseIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
addCaseReviewFunctionalCase(caseIds, userId, caseReviewId, caseReviewFunctionalCaseMapper);
|
||||||
//保存用例和用例评审人的关系
|
//保存用例和用例评审人的关系
|
||||||
addCaseReviewFunctionalCaseUser(caseIds, request.getReviewers(), caseReviewId, caseReviewFunctionalCaseUserMapper);
|
addCaseReviewFunctionalCaseUser(caseIds, reviewers, caseReviewId, caseReviewFunctionalCaseUserMapper);
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
} finally {
|
} finally {
|
||||||
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
|
||||||
|
@ -237,7 +237,8 @@ public class CaseReviewService {
|
||||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
|
||||||
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).distinct().toList();
|
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).distinct().toList();
|
||||||
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
CaseReview caseReview = addCaseReview(request, userId, caseReviewId, caseIds);
|
||||||
addAssociate(request, userId, caseReviewId, caseIds);
|
BaseAssociateCaseRequest baseAssociateCaseRequest = request.getBaseAssociateCaseRequest();
|
||||||
|
addAssociate(request, userId, caseReviewId, caseIds, baseAssociateCaseRequest.getReviewers());
|
||||||
return caseReview;
|
return caseReview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ public class CaseReviewControllerTests extends BaseTest {
|
||||||
tags.add("11");
|
tags.add("11");
|
||||||
caseReviewRequest.setTags(tags);
|
caseReviewRequest.setTags(tags);
|
||||||
}
|
}
|
||||||
|
baseAssociateCaseRequest.setReviewers(reviewers);
|
||||||
caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
|
caseReviewRequest.setBaseAssociateCaseRequest(baseAssociateCaseRequest);
|
||||||
return caseReviewRequest;
|
return caseReviewRequest;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue