From 72e553f1e2dba019029e5200439d9e7180f9f322 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Fri, 1 Nov 2024 12:34:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=92=8C=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E8=B7=A8=E9=A1=B9=E7=9B=AE=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=AF=A6=E6=83=85=EF=BC=8C=E6=8A=A5=E6=9D=83=E9=99=90?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1041793 --user=陈建星 【测试跟踪】测试计划/用例评审-关联其他项目的功能用例-测试计划内执行功能用例提示「当前用户没有操作此用例的权限」 https://www.tapd.cn/55049933/s/1604053 --- .../controller/TestPlanTestCaseController.java | 8 ++++---- .../controller/TestReviewTestCaseController.java | 8 +++++--- .../plan/service/TestPlanTestCaseService.java | 4 ++-- .../service/TestReviewTestCaseService.java | 16 ++++++++++++---- .../case/components/TestCaseTestRelate.vue | 5 ----- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java index a6c430fa2a..ebd133df87 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java @@ -99,11 +99,11 @@ public class TestPlanTestCaseController { return testPlanTestCaseService.listByNodes(request); } - @GetMapping("/get/{caseId}") + @GetMapping("/get/{id}") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ) - public TestPlanCaseDTO getTestPlanCases(@PathVariable String caseId) { - TestPlanCaseDTO testPlanCaseDTO = testPlanTestCaseService.get(caseId); - testPlanTestCaseService.checkPlanCaseOwner(testPlanCaseDTO.getCaseId(), SessionUtils.getUser(), SessionUtils.getUserId()); + public TestPlanCaseDTO getTestPlanCases(@PathVariable String id) { + TestPlanCaseDTO testPlanCaseDTO = testPlanTestCaseService.get(id); + testPlanTestCaseService.checkPlanCaseOwner(testPlanCaseDTO.getPlanId(), SessionUtils.getUser()); return testPlanCaseDTO; } diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestReviewTestCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestReviewTestCaseController.java index 9a627b7bd2..a71bb96384 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestReviewTestCaseController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestReviewTestCaseController.java @@ -101,10 +101,12 @@ public class TestReviewTestCaseController { return testReviewTestCaseService.editTestCase(testCaseReviewTestCase); } - @GetMapping("/get/{reviewId}") + @GetMapping("/get/{id}") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ) - public TestReviewCaseDTO get(@PathVariable String reviewId) { - return testReviewTestCaseService.get(reviewId, SessionUtils.getUserId()); + public TestReviewCaseDTO get(@PathVariable String id) { + TestReviewCaseDTO testReviewCaseDTO = testReviewTestCaseService.get(id); + testReviewTestCaseService.checkReviewCaseOwner(testReviewCaseDTO.getReviewId(), SessionUtils.getUser()); + return testReviewCaseDTO; } @GetMapping("/reviewer/status/{id}") diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java index 1458be4eea..335a6a6cc1 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java @@ -674,7 +674,7 @@ public class TestPlanTestCaseService { return updateIsDel(caseIds, false); } - public void checkPlanCaseOwner(String caseId, SessionUser sessionUser, String userId) { + public void checkPlanCaseOwner(String planId, SessionUser sessionUser) { long count = sessionUser.getGroups() .stream() .filter(g -> StringUtils.equals(g.getId(), UserGroupConstants.SUPER_GROUP)) @@ -682,7 +682,7 @@ public class TestPlanTestCaseService { if (count > 0) { return; } - boolean hasPermission = extCheckOwnerMapper.checkoutOwner("test_case", userId, List.of(caseId)); + boolean hasPermission = extCheckOwnerMapper.checkoutOwner("test_plan", sessionUser.getId(), List.of(planId)); if (!hasPermission) { MSException.throwException(Translator.get("check_owner_case")); } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java index 24fdb4352b..decfe21c83 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java @@ -7,7 +7,9 @@ import io.metersphere.base.mapper.ext.ExtTestCaseReviewTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.commons.constants.TestCaseReviewStatus; import io.metersphere.commons.constants.TestPlanStatus; +import io.metersphere.commons.constants.UserGroupConstants; import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.*; import io.metersphere.constants.TestCaseCommentType; import io.metersphere.constants.TestCaseReviewCommentStatus; @@ -469,9 +471,8 @@ public class TestReviewTestCaseService { return comments; } - public TestReviewCaseDTO get(String testReviewTestCaseId, String currentUserId) { + public TestReviewCaseDTO get(String testReviewTestCaseId) { TestReviewCaseDTO testReviewCaseDTO = extTestReviewCaseMapper.get(testReviewTestCaseId); - checkReviewCaseOwner(testReviewCaseDTO.getCaseId(), currentUserId); testReviewCaseDTO.setFields(testCaseService.getCustomFieldByCaseId(testReviewCaseDTO.getCaseId())); return testReviewCaseDTO; } @@ -891,8 +892,15 @@ public class TestReviewTestCaseService { } } - private void checkReviewCaseOwner(String caseId, String currentUserId) { - boolean hasPermission = extCheckOwnerMapper.checkoutOwner("test_case", currentUserId, List.of(caseId)); + public void checkReviewCaseOwner(String reviewId, SessionUser sessionUser) { + long count = sessionUser.getGroups() + .stream() + .filter(g -> StringUtils.equals(g.getId(), UserGroupConstants.SUPER_GROUP)) + .count(); + if (count > 0) { + return; + } + boolean hasPermission = extCheckOwnerMapper.checkoutOwner("test_case_review", sessionUser.getId(), List.of(reviewId)); if (!hasPermission) { MSException.throwException(Translator.get("check_owner_case")); } diff --git a/test-track/frontend/src/business/case/components/TestCaseTestRelate.vue b/test-track/frontend/src/business/case/components/TestCaseTestRelate.vue index 7546a80d33..2f93752e68 100644 --- a/test-track/frontend/src/business/case/components/TestCaseTestRelate.vue +++ b/test-track/frontend/src/business/case/components/TestCaseTestRelate.vue @@ -118,11 +118,6 @@ export default { } }, props: ['caseId', 'readOnly', 'versionEnable'], - watch: { - caseId() { - this.initTable(); - } - }, methods: { handleCommand(key) { if (!this.caseId) {