refactor(权限管理): 修改 checkowner
This commit is contained in:
parent
62f921bdec
commit
058b31af01
|
@ -15,6 +15,6 @@ public interface ExtApiTestMapper {
|
||||||
|
|
||||||
List<ApiTest> listByIds(@Param("ids") List<String> ids);
|
List<ApiTest> listByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
int checkApiTestOwner(@Param("testId") String testId, @Param("workspaceIds") Set<String> workspaceIds);
|
int checkApiTestOwner(@Param("testId") String testId, @Param("projectIds") Set<String> projectIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,9 +167,9 @@
|
||||||
<if test="testId != null">
|
<if test="testId != null">
|
||||||
and api_test.id = #{testId}
|
and api_test.id = #{testId}
|
||||||
</if>
|
</if>
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND workspace_id IN
|
AND project_id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -15,7 +15,7 @@ public interface ExtLoadTestMapper {
|
||||||
|
|
||||||
List<LoadTest> getLoadTestByProjectId(String projectId);
|
List<LoadTest> getLoadTestByProjectId(String projectId);
|
||||||
|
|
||||||
int checkLoadTestOwner(@Param("testId") String testId, @Param("workspaceIds") Set<String> workspaceIds);
|
int checkLoadTestOwner(@Param("testId") String testId, @Param("projectIds") Set<String> projectIds);
|
||||||
|
|
||||||
LoadTest getNextNum(@Param("projectId") String projectId);
|
LoadTest getNextNum(@Param("projectId") String projectId);
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,9 @@
|
||||||
<if test="testId != null">
|
<if test="testId != null">
|
||||||
and load_test.id = #{testId}
|
and load_test.id = #{testId}
|
||||||
</if>
|
</if>
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND workspace_id IN
|
AND project_id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -54,10 +54,10 @@ public interface ExtTestCaseMapper {
|
||||||
* 检查某工作空间下是否有某用例
|
* 检查某工作空间下是否有某用例
|
||||||
*
|
*
|
||||||
* @param caseId
|
* @param caseId
|
||||||
* @param workspaceIds
|
* @param projectIds
|
||||||
* @return TestCase ID
|
* @return TestCase ID
|
||||||
*/
|
*/
|
||||||
int checkIsHave(@Param("caseId") String caseId, @Param("workspaceIds") Set<String> workspaceIds);
|
int checkIsHave(@Param("caseId") String caseId, @Param("projectIds") Set<String> projectIds);
|
||||||
|
|
||||||
List<String> selectIds(@Param("request") BaseQueryRequest condition);
|
List<String> selectIds(@Param("request") BaseQueryRequest condition);
|
||||||
|
|
||||||
|
|
|
@ -256,9 +256,9 @@
|
||||||
SELECT COUNT(1)
|
SELECT COUNT(1)
|
||||||
FROM test_case, project
|
FROM test_case, project
|
||||||
WHERE test_case.project_id = project.id
|
WHERE test_case.project_id = project.id
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND project.workspace_id IN
|
AND project.id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
|
|
@ -18,11 +18,11 @@ public interface ExtTestCaseReviewMapper {
|
||||||
List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request);
|
List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查某工作空间下是否有某测试评审
|
* 检查某项目是否有某测试评审
|
||||||
*
|
*
|
||||||
* @param reviewId
|
* @param reviewId
|
||||||
* @param workspaceIds
|
* @param projectIds
|
||||||
* @return Review ID
|
* @return Review ID
|
||||||
*/
|
*/
|
||||||
int checkIsHave(@Param("reviewId") String reviewId, @Param("workspaceIds") Set<String> workspaceIds);
|
int checkIsHave(@Param("reviewId") String reviewId, @Param("projectIds") Set<String> projectIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,18 +79,18 @@
|
||||||
SELECT COUNT(1) as c
|
SELECT COUNT(1) as c
|
||||||
FROM project, test_case_review_project
|
FROM project, test_case_review_project
|
||||||
WHERE project.id = test_case_review_project.project_id AND test_case_review_project.review_id = #{reviewId}
|
WHERE project.id = test_case_review_project.project_id AND test_case_review_project.review_id = #{reviewId}
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND project.workspace_id IN
|
AND project.id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
union
|
union
|
||||||
select count(1) as c from test_case_review, project
|
select count(1) as c from test_case_review, project
|
||||||
WHERE project_id = project.id AND test_case_review.id = #{reviewId}
|
WHERE project_id = project.id AND test_case_review.id = #{reviewId}
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND project.workspace_id IN
|
AND project_id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>) as temp
|
</if>) as temp
|
||||||
|
|
|
@ -26,7 +26,7 @@ public interface ExtTestPlanMapper {
|
||||||
*/
|
*/
|
||||||
List<TestPlanDTO> selectTestPlanByRelevancy(@Param("request") QueryTestPlanRequest params);
|
List<TestPlanDTO> selectTestPlanByRelevancy(@Param("request") QueryTestPlanRequest params);
|
||||||
|
|
||||||
int checkIsHave(@Param("planId") String planId, @Param("workspaceIds") Set<String> workspaceIds);
|
int checkIsHave(@Param("planId") String planId, @Param("projectIds") Set<String> projectIds);
|
||||||
|
|
||||||
String findTestProjectNameByTestPlanID(String testPlanId);
|
String findTestProjectNameByTestPlanID(String testPlanId);
|
||||||
|
|
||||||
|
|
|
@ -196,18 +196,18 @@
|
||||||
SELECT COUNT(1) as c
|
SELECT COUNT(1) as c
|
||||||
FROM test_plan_project, project
|
FROM test_plan_project, project
|
||||||
WHERE project_id = project.id AND test_plan_id = #{planId}
|
WHERE project_id = project.id AND test_plan_id = #{planId}
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND project.workspace_id IN
|
AND project.id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
union
|
union
|
||||||
select count(1) as c from test_plan, project
|
select count(1) as c from test_plan, project
|
||||||
WHERE project_id = project.id AND test_plan.id = #{planId}
|
WHERE project_id = project.id AND test_plan.id = #{planId}
|
||||||
<if test="workspaceIds != null and workspaceIds.size() > 0">
|
<if test="projectIds != null and projectIds.size() > 0">
|
||||||
AND project.workspace_id IN
|
AND project.id IN
|
||||||
<foreach collection="workspaceIds" item="id" separator="," open="(" close=")">
|
<foreach collection="projectIds" item="id" separator="," open="(" close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>) as temp
|
</if>) as temp
|
||||||
|
|
|
@ -2,7 +2,6 @@ package io.metersphere.service;
|
||||||
|
|
||||||
import io.metersphere.base.domain.Group;
|
import io.metersphere.base.domain.Group;
|
||||||
import io.metersphere.base.domain.UserGroup;
|
import io.metersphere.base.domain.UserGroup;
|
||||||
import io.metersphere.base.mapper.ProjectMapper;
|
|
||||||
import io.metersphere.base.mapper.ext.*;
|
import io.metersphere.base.mapper.ext.*;
|
||||||
import io.metersphere.commons.constants.UserGroupType;
|
import io.metersphere.commons.constants.UserGroupType;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
|
@ -19,8 +18,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CheckPermissionService {
|
public class CheckPermissionService {
|
||||||
@Resource
|
|
||||||
private ProjectMapper projectMapper;
|
|
||||||
@Resource
|
@Resource
|
||||||
private ExtApiTestMapper extApiTestMapper;
|
private ExtApiTestMapper extApiTestMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -59,12 +56,12 @@ public class CheckPermissionService {
|
||||||
if (StringUtils.equals("other", testId)) {
|
if (StringUtils.equals("other", testId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> workspaceIds = getUserRelatedProjectIds();
|
Set<String> projectIds = getUserRelatedProjectIds();
|
||||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
if (CollectionUtils.isEmpty(projectIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = extApiTestMapper.checkApiTestOwner(testId, workspaceIds);
|
int result = extApiTestMapper.checkApiTestOwner(testId, projectIds);
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new RuntimeException(Translator.get("check_owner_test"));
|
throw new RuntimeException(Translator.get("check_owner_test"));
|
||||||
|
@ -76,11 +73,11 @@ public class CheckPermissionService {
|
||||||
if (StringUtils.equals("other", testId)) {
|
if (StringUtils.equals("other", testId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<String> workspaceIds = getUserRelatedProjectIds();
|
Set<String> projectIds = getUserRelatedProjectIds();
|
||||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
if (CollectionUtils.isEmpty(projectIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int result = extLoadTestMapper.checkLoadTestOwner(testId, workspaceIds);
|
int result = extLoadTestMapper.checkLoadTestOwner(testId, projectIds);
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new RuntimeException(Translator.get("check_owner_test"));
|
throw new RuntimeException(Translator.get("check_owner_test"));
|
||||||
|
@ -88,34 +85,34 @@ public class CheckPermissionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTestCaseOwner(String caseId) {
|
public void checkTestCaseOwner(String caseId) {
|
||||||
Set<String> workspaceIds = getUserRelatedProjectIds();
|
Set<String> projectIds = getUserRelatedProjectIds();
|
||||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
if (CollectionUtils.isEmpty(projectIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = extTestCaseMapper.checkIsHave(caseId, workspaceIds);
|
int result = extTestCaseMapper.checkIsHave(caseId, projectIds);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new RuntimeException(Translator.get("check_owner_case"));
|
throw new RuntimeException(Translator.get("check_owner_case"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTestPlanOwner(String planId) {
|
public void checkTestPlanOwner(String planId) {
|
||||||
Set<String> workspaceIds = getUserRelatedProjectIds();
|
Set<String> projectIds = getUserRelatedProjectIds();
|
||||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
if (CollectionUtils.isEmpty(projectIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int result = extTestPlanMapper.checkIsHave(planId, workspaceIds);
|
int result = extTestPlanMapper.checkIsHave(planId, projectIds);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new RuntimeException(Translator.get("check_owner_plan"));
|
throw new RuntimeException(Translator.get("check_owner_plan"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkTestReviewOwner(String reviewId) {
|
public void checkTestReviewOwner(String reviewId) {
|
||||||
Set<String> workspaceIds = getUserRelatedProjectIds();
|
Set<String> projectIds = getUserRelatedProjectIds();
|
||||||
if (CollectionUtils.isEmpty(workspaceIds)) {
|
if (CollectionUtils.isEmpty(projectIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int result = extTestCaseReviewMapper.checkIsHave(reviewId, workspaceIds);
|
int result = extTestCaseReviewMapper.checkIsHave(reviewId, projectIds);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
throw new RuntimeException(Translator.get("check_owner_review"));
|
throw new RuntimeException(Translator.get("check_owner_review"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue