From 36e7c48b1c0351942b4c31ae2cce8ed2507e8f09 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 21 Aug 2024 17:22:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):?= =?UTF-8?q?=20=E8=AF=84=E5=AE=A1=E5=88=A0=E9=99=A4=E5=90=8E=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E8=AF=84=E5=AE=A1=E7=94=A8=E4=BE=8B=E7=9A=84=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functional/provider/CaseReviewCaseProvider.java | 8 ++++++++ .../functional/service/DeleteCaseReviewService.java | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java index 161a24d536..bf739695f7 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java @@ -120,6 +120,14 @@ public class CaseReviewCaseProvider implements BaseCaseProvider { } } + @Async + public void refreshReviewCaseStatus(List reviewCases) { + if (CollectionUtils.isNotEmpty(reviewCases)) { + List caseIds = reviewCases.stream().map(CaseReviewFunctionalCase::getCaseId).collect(Collectors.toList()); + updateCaseStatus(caseIds); + } + } + private void updateCaseStatus(List caseIdList) { CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIdList); diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/DeleteCaseReviewService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/DeleteCaseReviewService.java index 00f6bf7fd1..30e9425a40 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/DeleteCaseReviewService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/DeleteCaseReviewService.java @@ -2,11 +2,14 @@ package io.metersphere.functional.service; import io.metersphere.functional.domain.*; import io.metersphere.functional.mapper.*; +import io.metersphere.functional.provider.CaseReviewCaseProvider; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @author guoyuqi @@ -27,12 +30,15 @@ public class DeleteCaseReviewService { private CaseReviewFollowerMapper caseReviewFollowerMapper; @Resource private CaseReviewHistoryMapper caseReviewHistoryMapper; + @Resource + private CaseReviewCaseProvider caseReviewCaseProvider; public void deleteCaseReviewResource(List ids, String projectId) { //TODO 删除各种关联关系? 1.关联用例(功能/接口/场景/ui/性能)? 2.评审和评审人 3. 归档的用例 4. 关注人 5.评审历史 6. 操作记录 //1.刪除评审与功能用例关联关系 CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); caseReviewFunctionalCaseExample.createCriteria().andReviewIdIn(ids); + List reviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); caseReviewFunctionalCaseMapper.deleteByExample(caseReviewFunctionalCaseExample); //2. 删除评审和评审人 CaseReviewUserExample caseReviewUserExample = new CaseReviewUserExample(); @@ -56,5 +62,9 @@ public class DeleteCaseReviewService { CaseReviewExample caseReviewExample = new CaseReviewExample(); caseReviewExample.createCriteria().andIdIn(ids).andProjectIdEqualTo(projectId); caseReviewMapper.deleteByExample(caseReviewExample); + + // 7. 批量刷新评审中其他用例的评审状态 + Map> reviewFunctionalCaseMap = reviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getReviewId)); + reviewFunctionalCaseMap.forEach((reviewId, reviewFunctionalCaseList) -> caseReviewCaseProvider.refreshReviewCaseStatus(reviewFunctionalCaseList)); } }