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) {