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