diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java index 7bb4644b6c..e448c44803 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.java @@ -15,6 +15,6 @@ public interface ExtApiTestMapper { List listByIds(@Param("ids") List ids); - int checkApiTestOwner(@Param("testId") String testId, @Param("workspaceIds") Set workspaceIds); + int checkApiTestOwner(@Param("testId") String testId, @Param("projectIds") Set projectIds); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml index 6d8a99a761..bef905fe86 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestMapper.xml @@ -167,9 +167,9 @@ and api_test.id = #{testId} - - AND workspace_id IN - + + AND project_id IN + #{id} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java index a6c67b6c5b..794382bb4f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.java @@ -15,7 +15,7 @@ public interface ExtLoadTestMapper { List getLoadTestByProjectId(String projectId); - int checkLoadTestOwner(@Param("testId") String testId, @Param("workspaceIds") Set workspaceIds); + int checkLoadTestOwner(@Param("testId") String testId, @Param("projectIds") Set projectIds); LoadTest getNextNum(@Param("projectId") String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml index 2eb995b3d8..c603ece9af 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml @@ -125,9 +125,9 @@ and load_test.id = #{testId} - - AND workspace_id IN - + + AND project_id IN + #{id} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index dc66c2ab6b..d1e8651846 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -54,10 +54,10 @@ public interface ExtTestCaseMapper { * 检查某工作空间下是否有某用例 * * @param caseId - * @param workspaceIds + * @param projectIds * @return TestCase ID */ - int checkIsHave(@Param("caseId") String caseId, @Param("workspaceIds") Set workspaceIds); + int checkIsHave(@Param("caseId") String caseId, @Param("projectIds") Set projectIds); List selectIds(@Param("request") BaseQueryRequest condition); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 39b95cbb1b..618087fa98 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -256,9 +256,9 @@ SELECT COUNT(1) FROM test_case, project WHERE test_case.project_id = project.id - - AND project.workspace_id IN - + + AND project.id IN + #{id} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java index 9d9d453caf..ccadcab5fa 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.java @@ -18,11 +18,11 @@ public interface ExtTestCaseReviewMapper { List listRelate(@Param("request") QueryTestReviewRequest request); /** - * 检查某工作空间下是否有某测试评审 + * 检查某项目是否有某测试评审 * * @param reviewId - * @param workspaceIds + * @param projectIds * @return Review ID */ - int checkIsHave(@Param("reviewId") String reviewId, @Param("workspaceIds") Set workspaceIds); + int checkIsHave(@Param("reviewId") String reviewId, @Param("projectIds") Set projectIds); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml index e6ec55e692..9c9ff74aea 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseReviewMapper.xml @@ -79,18 +79,18 @@ SELECT COUNT(1) as c FROM project, test_case_review_project WHERE project.id = test_case_review_project.project_id AND test_case_review_project.review_id = #{reviewId} - - AND project.workspace_id IN - + + AND project.id IN + #{id} union select count(1) as c from test_case_review, project WHERE project_id = project.id AND test_case_review.id = #{reviewId} - - AND project.workspace_id IN - + + AND project_id IN + #{id} ) as temp diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java index c29727c077..db1adf8ac2 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java @@ -26,7 +26,7 @@ public interface ExtTestPlanMapper { */ List selectTestPlanByRelevancy(@Param("request") QueryTestPlanRequest params); - int checkIsHave(@Param("planId") String planId, @Param("workspaceIds") Set workspaceIds); + int checkIsHave(@Param("planId") String planId, @Param("projectIds") Set projectIds); String findTestProjectNameByTestPlanID(String testPlanId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index af35e4b954..14096425f5 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -196,18 +196,18 @@ SELECT COUNT(1) as c FROM test_plan_project, project WHERE project_id = project.id AND test_plan_id = #{planId} - - AND project.workspace_id IN - + + AND project.id IN + #{id} union select count(1) as c from test_plan, project WHERE project_id = project.id AND test_plan.id = #{planId} - - AND project.workspace_id IN - + + AND project.id IN + #{id} ) as temp diff --git a/backend/src/main/java/io/metersphere/service/CheckPermissionService.java b/backend/src/main/java/io/metersphere/service/CheckPermissionService.java index 123afed15f..599be37c4f 100644 --- a/backend/src/main/java/io/metersphere/service/CheckPermissionService.java +++ b/backend/src/main/java/io/metersphere/service/CheckPermissionService.java @@ -2,7 +2,6 @@ package io.metersphere.service; import io.metersphere.base.domain.Group; import io.metersphere.base.domain.UserGroup; -import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.UserGroupType; import io.metersphere.commons.utils.SessionUtils; @@ -19,8 +18,6 @@ import java.util.stream.Collectors; @Service public class CheckPermissionService { - @Resource - private ProjectMapper projectMapper; @Resource private ExtApiTestMapper extApiTestMapper; @Resource @@ -59,12 +56,12 @@ public class CheckPermissionService { if (StringUtils.equals("other", testId)) { return; } - Set workspaceIds = getUserRelatedProjectIds(); - if (CollectionUtils.isEmpty(workspaceIds)) { + Set projectIds = getUserRelatedProjectIds(); + if (CollectionUtils.isEmpty(projectIds)) { return; } - int result = extApiTestMapper.checkApiTestOwner(testId, workspaceIds); + int result = extApiTestMapper.checkApiTestOwner(testId, projectIds); if (result == 0) { throw new RuntimeException(Translator.get("check_owner_test")); @@ -76,11 +73,11 @@ public class CheckPermissionService { if (StringUtils.equals("other", testId)) { return; } - Set workspaceIds = getUserRelatedProjectIds(); - if (CollectionUtils.isEmpty(workspaceIds)) { + Set projectIds = getUserRelatedProjectIds(); + if (CollectionUtils.isEmpty(projectIds)) { return; } - int result = extLoadTestMapper.checkLoadTestOwner(testId, workspaceIds); + int result = extLoadTestMapper.checkLoadTestOwner(testId, projectIds); if (result == 0) { throw new RuntimeException(Translator.get("check_owner_test")); @@ -88,34 +85,34 @@ public class CheckPermissionService { } public void checkTestCaseOwner(String caseId) { - Set workspaceIds = getUserRelatedProjectIds(); - if (CollectionUtils.isEmpty(workspaceIds)) { + Set projectIds = getUserRelatedProjectIds(); + if (CollectionUtils.isEmpty(projectIds)) { return; } - int result = extTestCaseMapper.checkIsHave(caseId, workspaceIds); + int result = extTestCaseMapper.checkIsHave(caseId, projectIds); if (result == 0) { throw new RuntimeException(Translator.get("check_owner_case")); } } public void checkTestPlanOwner(String planId) { - Set workspaceIds = getUserRelatedProjectIds(); - if (CollectionUtils.isEmpty(workspaceIds)) { + Set projectIds = getUserRelatedProjectIds(); + if (CollectionUtils.isEmpty(projectIds)) { return; } - int result = extTestPlanMapper.checkIsHave(planId, workspaceIds); + int result = extTestPlanMapper.checkIsHave(planId, projectIds); if (result == 0) { throw new RuntimeException(Translator.get("check_owner_plan")); } } public void checkTestReviewOwner(String reviewId) { - Set workspaceIds = getUserRelatedProjectIds(); - if (CollectionUtils.isEmpty(workspaceIds)) { + Set projectIds = getUserRelatedProjectIds(); + if (CollectionUtils.isEmpty(projectIds)) { return; } - int result = extTestCaseReviewMapper.checkIsHave(reviewId, workspaceIds); + int result = extTestCaseReviewMapper.checkIsHave(reviewId, projectIds); if (result == 0) { throw new RuntimeException(Translator.get("check_owner_review")); }