refactor(用例管理): 修改一些代码

This commit is contained in:
guoyuqi 2024-08-22 10:47:28 +08:00 committed by Craftsman
parent d02b153dea
commit b4d6f67cc6
2 changed files with 3 additions and 37 deletions

View File

@ -159,9 +159,9 @@ public class CaseReviewModuleService extends ModuleTreeService {
if (CollectionUtils.isNotEmpty(caseReviewList)) { if (CollectionUtils.isNotEmpty(caseReviewList)) {
caseReviews.addAll(caseReviewList); caseReviews.addAll(caseReviewList);
} }
List<String> caseIds = caseReviewList.stream().map(CaseReview::getId).toList(); List<String> reviewIds = caseReviewList.stream().map(CaseReview::getId).toList();
if (CollectionUtils.isNotEmpty(caseIds)) { if (CollectionUtils.isNotEmpty(reviewIds)) {
deleteCaseReviewService.deleteCaseReviewResource(caseIds, projectId); deleteCaseReviewService.deleteCaseReviewResource(reviewIds, projectId);
} }
List<String> childrenIds = extCaseReviewModuleMapper.selectChildrenIdsByParentIds(deleteIds); List<String> childrenIds = extCaseReviewModuleMapper.selectChildrenIdsByParentIds(deleteIds);
if (CollectionUtils.isNotEmpty(childrenIds)) { if (CollectionUtils.isNotEmpty(childrenIds)) {

View File

@ -617,41 +617,7 @@ public class CaseReviewService {
} }
public void deleteCaseReview(String reviewId, String projectId) { public void deleteCaseReview(String reviewId, String projectId) {
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId);
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
List<String> caseIds = caseReviewFunctionalCases.stream().map(CaseReviewFunctionalCase::getCaseId).toList();
deleteCaseReviewService.deleteCaseReviewResource(List.of(reviewId), projectId); deleteCaseReviewService.deleteCaseReviewResource(List.of(reviewId), projectId);
//将用例置为上一次的评审的结果
if (CollectionUtils.isEmpty(caseIds)) {
return;
}
caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIds);
caseReviewFunctionalCaseExample.setOrderByClause("update_time DESC");
caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
Map<String, List<CaseReviewFunctionalCase>> caseReviewMap = caseReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId));
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class);
try {
for (String caseId : caseIds) {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setId(caseId);
String status;
List<CaseReviewFunctionalCase> statuList = caseReviewMap.get(caseId);
if (CollectionUtils.isNotEmpty(statuList)) {
List<CaseReviewFunctionalCase> list = statuList.stream().sorted(Comparator.comparing(CaseReviewFunctionalCase::getUpdateTime).reversed()).toList();
status = list.getFirst().getStatus();
} else {
status = FunctionalCaseReviewStatus.UN_REVIEWED.toString();
}
functionalCase.setReviewStatus(status);
mapper.updateByPrimaryKeySelective(functionalCase);
}
sqlSession.flushStatements();
} finally {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
} }
public void disassociate(String reviewId, String caseId, String userId) { public void disassociate(String reviewId, String caseId, String userId) {