From 7c6fb6a01371e9de8a92a15a32382c607c70bfb3 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 22 Nov 2022 14:53:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E5=8F=96=E6=B6=88=E5=85=B3=E8=81=94=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=EF=BC=8C=E4=BC=9A=E6=8A=8A=E8=AF=A5=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E5=85=B3=E8=81=94=E4=B8=8E=E5=85=B6=E4=BB=96=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020038 --user=陈建星 【测试跟踪】测试用例-关联jira缺陷-缺陷管理-取消关联用例-再次查看用例,关联的所有缺陷都被取消了 https://www.tapd.cn/55049933/s/1301042 --- .../io/metersphere/service/IssuesService.java | 13 +++++++--- .../issue/platform/AbstractIssuePlatform.java | 25 +------------------ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index c5338969ab..1bf008d94a 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -298,20 +298,25 @@ public class IssuesService { } } - protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { + public void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { String issuesId = issuesRequest.getId(); List deleteCaseIds = issuesRequest.getDeleteResourceIds(); if (!org.springframework.util.CollectionUtils.isEmpty(deleteCaseIds)) { TestCaseIssuesExample example = new TestCaseIssuesExample(); - example.createCriteria().andResourceIdIn(deleteCaseIds); + example.createCriteria() + .andResourceIdIn(deleteCaseIds) + .andIssuesIdEqualTo(issuesId); // 测试计划的用例 deleteCaseIds 是空的, 不会进到这里 - example.or(example.createCriteria().andRefIdIn(deleteCaseIds)); + example.or( + example.createCriteria() + .andRefIdIn(deleteCaseIds) + .andIssuesIdEqualTo(issuesId) + ); testCaseIssuesMapper.deleteByExample(example); } List addCaseIds = issuesRequest.getAddResourceIds(); - TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class); if (!org.springframework.util.CollectionUtils.isEmpty(addCaseIds)) { if (issuesRequest.getIsPlanEdit()) { diff --git a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java index aa3ac12a78..340cc88250 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java +++ b/test-track/backend/src/main/java/io/metersphere/service/issue/platform/AbstractIssuePlatform.java @@ -164,30 +164,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { } protected void handleTestCaseIssues(IssuesUpdateRequest issuesRequest) { - String issuesId = issuesRequest.getId(); - List deleteCaseIds = issuesRequest.getDeleteResourceIds(); - - if (!CollectionUtils.isEmpty(deleteCaseIds)) { - TestCaseIssuesExample example = new TestCaseIssuesExample(); - example.createCriteria().andResourceIdIn(deleteCaseIds); - // 测试计划的用例 deleteCaseIds 是空的, 不会进到这里 - example.or(example.createCriteria().andRefIdIn(deleteCaseIds)); - testCaseIssuesMapper.deleteByExample(example); - } - - List addCaseIds = issuesRequest.getAddResourceIds(); - TestCaseIssueService testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class); - - if (!CollectionUtils.isEmpty(addCaseIds)) { - if (issuesRequest.getIsPlanEdit()) { - addCaseIds.forEach(caseId -> { - testCaseIssueService.add(issuesId, caseId, issuesRequest.getRefId(), IssueRefType.PLAN_FUNCTIONAL.name()); - testCaseIssueService.updateIssuesCount(caseId); - }); - } else { - addCaseIds.forEach(caseId -> testCaseIssueService.add(issuesId, caseId, null, IssueRefType.FUNCTIONAL.name())); - } - } + issuesService.handleTestCaseIssues(issuesRequest); } protected void insertIssuesWithoutContext(String id, IssuesUpdateRequest issuesRequest) {