From b92ed2ab07b8f68fe38c6bec2a9f22c5446bde0d Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Wed, 30 Oct 2024 11:57:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=B6=85=E7=AE=A1=E6=97=A0=E6=B3=95=E6=9F=A5=E7=9C=8B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1040309 --user=陈建星 [测试跟踪] github #30599超级管理员角色执行功能用例,没有更新执行人 https://www.tapd.cn/55049933/s/1601913 --- .../controller/TestPlanTestCaseController.java | 4 +++- .../plan/service/TestPlanTestCaseService.java | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 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 88f278e87c..a6c430fa2a 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 @@ -102,7 +102,9 @@ public class TestPlanTestCaseController { @GetMapping("/get/{caseId}") @RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ) public TestPlanCaseDTO getTestPlanCases(@PathVariable String caseId) { - return testPlanTestCaseService.get(caseId, SessionUtils.getUserId()); + TestPlanCaseDTO testPlanCaseDTO = testPlanTestCaseService.get(caseId); + testPlanTestCaseService.checkPlanCaseOwner(testPlanCaseDTO.getCaseId(), SessionUtils.getUser(), SessionUtils.getUserId()); + return testPlanCaseDTO; } @PostMapping("recent/{count}") 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 329a382303..63dedccf8a 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 @@ -11,6 +11,7 @@ import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.commons.constants.IssueRefType; import io.metersphere.commons.constants.MicroServiceName; import io.metersphere.commons.constants.ProjectApplicationType; +import io.metersphere.commons.constants.UserGroupConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.*; @@ -309,9 +310,8 @@ public class TestPlanTestCaseService { request.setExecutor(user.getId()); } - public TestPlanCaseDTO get(String id, String userId) { + public TestPlanCaseDTO get(String id) { TestPlanCaseDTO testPlanCaseDTO = extTestPlanTestCaseMapper.get(id); - checkPlanCaseOwner(testPlanCaseDTO.getCaseId(), userId); ServiceUtils.buildCustomNumInfo(testPlanCaseDTO); List testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testPlanCaseDTO.getCaseId()); testCaseTestDTOS.forEach(this::setTestName); @@ -668,7 +668,14 @@ public class TestPlanTestCaseService { return updateIsDel(caseIds, false); } - private void checkPlanCaseOwner(String caseId, String userId) { + public void checkPlanCaseOwner(String caseId, SessionUser sessionUser, String userId) { + 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", userId, List.of(caseId)); if (!hasPermission) { MSException.throwException(Translator.get("check_owner_case"));