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); deleteCaseReviewProject(reviewId);
deleteCaseReviewUsers(reviewId); deleteCaseReviewUsers(reviewId);
deleteCaseReviewFollow(reviewId); deleteCaseReviewFollow(reviewId);
// 批量刷新该评审下用例的评审状态(异步)
TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample();
example.createCriteria().andReviewIdEqualTo(reviewId);
List<TestCaseReviewTestCase> testCaseReviewTestCases = testCaseReviewTestCaseMapper.selectByExample(example);
testReviewTestCaseService.refreshReviewCaseStatus(testCaseReviewTestCases);
deleteCaseReviewTestCase(reviewId); deleteCaseReviewTestCase(reviewId);
testCaseReviewMapper.deleteByPrimaryKey(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.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -173,6 +174,15 @@ public class TestReviewTestCaseService {
return testCaseReviewTestCaseMapper.updateByExampleSelective(record, example); 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) { private void rollBackCaseReviewStatus(String caseId, String relevanceId) {
TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample(); TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample();
example.createCriteria().andCaseIdEqualTo(caseId); example.createCriteria().andCaseIdEqualTo(caseId);
@ -182,7 +192,7 @@ public class TestReviewTestCaseService {
.sorted(Comparator.comparing(TestCaseReviewTestCase::getUpdateTime).reversed()) .sorted(Comparator.comparing(TestCaseReviewTestCase::getUpdateTime).reversed())
.map(TestCaseReviewTestCase::getStatus) .map(TestCaseReviewTestCase::getStatus)
.toList(); .toList();
if (remainReviewCaseStatusOrderByUpdate.size() > 0) { if (!remainReviewCaseStatusOrderByUpdate.isEmpty()) {
// 回退到最近的一次评审状态 // 回退到最近的一次评审状态
String latestStatus = remainReviewCaseStatusOrderByUpdate.get(0); String latestStatus = remainReviewCaseStatusOrderByUpdate.get(0);
TestCaseWithBLOBs testCase = new TestCaseWithBLOBs(); TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();