From d99a79ac0c0fafc78a3229a6ddd4bf8400f659e6 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 27 May 2024 16:14:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=88=A0=E9=99=A4=E6=9C=AA=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E4=BE=8B=E5=85=B3=E8=81=94=E7=9A=84?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1041252 --user=宋昌昌 【测试计划】删除计划-功能用例详情-缺陷-测试计划关联缺陷未同步删除 https://www.tapd.cn/55049933/s/1521488 --- .../plan/service/TestPlanBugService.java | 21 +------------------ .../TestPlanFunctionalCaseService.java | 4 ---- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java index 56b81a7473..a787071868 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanBugService.java @@ -1,6 +1,5 @@ package io.metersphere.plan.service; -import io.metersphere.bug.domain.BugRelationCase; import io.metersphere.bug.domain.BugRelationCaseExample; import io.metersphere.bug.mapper.BugRelationCaseMapper; import io.metersphere.bug.service.BugCommonService; @@ -13,7 +12,6 @@ import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.mapper.BaseUserMapper; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,24 +46,7 @@ public class TestPlanBugService extends TestPlanResourceService { public void deleteBatchByTestPlanId(List testPlanIdList) { BugRelationCaseExample example = new BugRelationCaseExample(); example.createCriteria().andTestPlanIdIn(testPlanIdList); - List bugRelationCases = bugRelationCaseMapper.selectByExample(example); - List relateIdsByDirect = bugRelationCases.stream().filter(relatedCase -> StringUtils.isNotEmpty(relatedCase.getCaseId())).map(BugRelationCase::getId).toList(); - List relateIdsByPlan = bugRelationCases.stream().filter(relatedCase -> StringUtils.isEmpty(relatedCase.getCaseId())).map(BugRelationCase::getId).toList(); - if (CollectionUtils.isNotEmpty(relateIdsByDirect)) { - // 缺陷-用例, 存在直接关联 - BugRelationCaseExample updateExample = new BugRelationCaseExample(); - updateExample.createCriteria().andIdIn(relateIdsByDirect); - BugRelationCase record = new BugRelationCase(); - record.setTestPlanId(StringUtils.EMPTY); - record.setTestPlanCaseId(StringUtils.EMPTY); - bugRelationCaseMapper.updateByExampleSelective(record, updateExample); - } - if (CollectionUtils.isNotEmpty(relateIdsByPlan)) { - // 缺陷-用例, 计划关联 - BugRelationCaseExample deleteExample = new BugRelationCaseExample(); - deleteExample.createCriteria().andIdIn(relateIdsByPlan); - bugRelationCaseMapper.deleteByExample(deleteExample); - } + bugRelationCaseMapper.deleteByExample(example); } @Override diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index c78b1823bc..059aef969b 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -114,10 +114,6 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { TestPlanFunctionalCaseExample testPlanFunctionalCaseExample = new TestPlanFunctionalCaseExample(); testPlanFunctionalCaseExample.createCriteria().andTestPlanIdIn(testPlanIdList); testPlanFunctionalCaseMapper.deleteByExample(testPlanFunctionalCaseExample); - // 取消关联用例需同步删除计划-用例缺陷关系表 - BugRelationCaseExample example = new BugRelationCaseExample(); - example.createCriteria().andTestPlanIdIn(testPlanIdList); - bugRelationCaseMapper.deleteByExample(example); // todo:song.tianyang 删除执行历史 testPlanFunctionalCaseMapper.deleteByExample(testPlanFunctionalCaseExample);