From 9242700b93678acc0ce5fbe1140ff1ceb7c121ec Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 27 Oct 2021 16:07:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=5F=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=5F?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E4=BA=BA=E6=8A=A5=E9=94=99=20--bug=3D1007510?= =?UTF-8?q?=20--user=3D=E7=8E=8B=E5=AD=9D=E5=88=9A=20=E3=80=90=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=B7=9F=E8=B8=AA=E3=80=91=E7=BC=96=E8=BE=91=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=AF=84=E5=AE=A1=E6=8A=A5=E9=94=99=20https://www.tap?= =?UTF-8?q?d.cn/55049933/s/1059880?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestCaseReviewService.java | 40 ++++++++++--------- .../track/service/TestPlanService.java | 3 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 049eb93adc..ae1bac49e2 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -266,25 +266,29 @@ public class TestCaseReviewService { private void editCaseRevieweFollow(SaveTestCaseReviewRequest testCaseReview) { // 要更新的follows List follows = testCaseReview.getFollowIds(); + if (CollectionUtils.isNotEmpty(follows)) { + String id = testCaseReview.getId(); + TestCaseReviewFollowExample testCaseReviewfollowExample = new TestCaseReviewFollowExample(); + testCaseReviewfollowExample.createCriteria().andReviewIdEqualTo(id); + List testCaseReviewFollows = testCaseReviewFollowMapper.selectByExample(testCaseReviewfollowExample); + List dbReviewIds = testCaseReviewFollows.stream().map(TestCaseReviewFollow::getFollowId).collect(Collectors.toList()); + follows.forEach(followId -> { + if (!dbReviewIds.contains(followId)) { + TestCaseReviewFollow caseReviewFollow = new TestCaseReviewFollow(); + caseReviewFollow.setFollowId(followId); + caseReviewFollow.setReviewId(id); + testCaseReviewFollowMapper.insertSelective(caseReviewFollow); + } + }); + TestCaseReviewFollowExample example = new TestCaseReviewFollowExample(); + example.createCriteria().andReviewIdEqualTo(id).andFollowIdNotIn(follows); + testCaseReviewFollowMapper.deleteByExample(example); + }else { + TestCaseReviewFollowExample example = new TestCaseReviewFollowExample(); + example.createCriteria().andReviewIdEqualTo(testCaseReview.getId()); + testCaseReviewFollowMapper.deleteByExample(example); + } - String id = testCaseReview.getId(); - TestCaseReviewFollowExample testCaseReviewfollowExample = new TestCaseReviewFollowExample(); - testCaseReviewfollowExample.createCriteria().andReviewIdEqualTo(id); - List testCaseReviewFollows = testCaseReviewFollowMapper.selectByExample(testCaseReviewfollowExample); - List dbReviewIds = testCaseReviewFollows.stream().map(TestCaseReviewFollow::getFollowId).collect(Collectors.toList()); - - follows.forEach(followId -> { - if (!dbReviewIds.contains(followId)) { - TestCaseReviewFollow caseReviewFollow = new TestCaseReviewFollow(); - caseReviewFollow.setFollowId(followId); - caseReviewFollow.setReviewId(id); - testCaseReviewFollowMapper.insertSelective(caseReviewFollow); - } - }); - - TestCaseReviewFollowExample example = new TestCaseReviewFollowExample(); - example.createCriteria().andReviewIdEqualTo(id).andFollowIdNotIn(follows); - testCaseReviewFollowMapper.deleteByExample(example); } private void checkCaseReviewExist(TestCaseReview testCaseReview) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index d02709bced..6e4be3cefd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -255,7 +255,6 @@ public class TestPlanService { } } List follows = request.getFollows(); - if (!CollectionUtils.isEmpty(follows)) { if (StringUtils.isNotBlank(request.getId())) { testPlanFollowService.deleteTestPlanFollowByPlanId(request.getId()); for (String follow : follows) { @@ -265,7 +264,7 @@ public class TestPlanService { testPlanFollowService.insert(testPlanFollow); } } - } + return this.editTestPlan(request); }