refactor(测试跟踪): 删除评审后刷新评审中用例的状态

This commit is contained in:
song-cc-rock 2024-08-20 13:51:48 +08:00 committed by Craftsman
parent 0cc886c06d
commit 2846e8461b
2 changed files with 16 additions and 1 deletions

View File

@ -437,6 +437,11 @@ public class TestCaseReviewService {
deleteCaseReviewProject(reviewId);
deleteCaseReviewUsers(reviewId);
deleteCaseReviewFollow(reviewId);
// 批量刷新该评审下用例的评审状态(异步)
TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample();
example.createCriteria().andReviewIdEqualTo(reviewId);
List<TestCaseReviewTestCase> testCaseReviewTestCases = testCaseReviewTestCaseMapper.selectByExample(example);
testReviewTestCaseService.refreshReviewCaseStatus(testCaseReviewTestCases);
deleteCaseReviewTestCase(reviewId);
testCaseReviewMapper.deleteByPrimaryKey(reviewId);
}

View File

@ -34,6 +34,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -173,6 +174,15 @@ public class TestReviewTestCaseService {
return testCaseReviewTestCaseMapper.updateByExampleSelective(record, example);
}
@Async
public void refreshReviewCaseStatus(List<TestCaseReviewTestCase> testCaseReviewTestCases) {
if (CollectionUtils.isNotEmpty(testCaseReviewTestCases)) {
testCaseReviewTestCases.forEach(testCaseReviewTestCase -> {
rollBackCaseReviewStatus(testCaseReviewTestCase.getCaseId(), testCaseReviewTestCase.getId());
});
}
}
private void rollBackCaseReviewStatus(String caseId, String relevanceId) {
TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample();
example.createCriteria().andCaseIdEqualTo(caseId);
@ -182,7 +192,7 @@ public class TestReviewTestCaseService {
.sorted(Comparator.comparing(TestCaseReviewTestCase::getUpdateTime).reversed())
.map(TestCaseReviewTestCase::getStatus)
.toList();
if (remainReviewCaseStatusOrderByUpdate.size() > 0) {
if (!remainReviewCaseStatusOrderByUpdate.isEmpty()) {
// 回退到最近的一次评审状态
String latestStatus = remainReviewCaseStatusOrderByUpdate.get(0);
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();