From 9205f028fd182e06d77dfae8c989d50c2c750fb5 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 13 Nov 2024 09:49:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E6=A0=A1=E9=AA=8C=E6=A8=A1=E5=9D=97=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/service/DashboardService.java | 18 ++++++------------ .../project/service/ProjectService.java | 7 +++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java index 7dda86ee06..3041e00890 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java @@ -558,7 +558,7 @@ public class DashboardService { public StatisticsDTO projectCaseCount(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); StatisticsDTO statisticsDTO = new StatisticsDTO(); - if (Boolean.FALSE.equals(checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { + if (Boolean.FALSE.equals(projectService.checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); return statisticsDTO; } @@ -578,12 +578,6 @@ public class DashboardService { return statisticsDTO; } - private Boolean checkModule(String projectId, String module) { - Project project = projectMapper.selectByPrimaryKey(projectId); - List moduleIds = JSON.parseArray(project.getModuleSetting(), String.class); - return moduleIds.contains(module); - } - @NotNull private static List getPassList(Map> reviewStatusMap, List statisticListByProjectId) { List passList = new ArrayList<>(); @@ -661,7 +655,7 @@ public class DashboardService { public StatisticsDTO projectAssociateCaseCount(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); StatisticsDTO statisticsDTO = new StatisticsDTO(); - if (Boolean.FALSE.equals(checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { + if (Boolean.FALSE.equals(projectService.checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); return statisticsDTO; } @@ -678,7 +672,7 @@ public class DashboardService { public OverViewCountDTO projectBugHandleUser(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); - if (Boolean.FALSE.equals(checkModule(projectId, BUG_MODULE))) + if (Boolean.FALSE.equals(projectService.checkModule(projectId, BUG_MODULE))) return new OverViewCountDTO(null, new ArrayList<>(), new ArrayList<>()); Long toStartTime = request.getToStartTime(); Long toEndTime = request.getToEndTime(); @@ -811,7 +805,7 @@ public class DashboardService { public StatisticsDTO projectReviewCaseCount(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); StatisticsDTO statisticsDTO = new StatisticsDTO(); - if (Boolean.FALSE.equals(checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { + if (Boolean.FALSE.equals(projectService.checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); return statisticsDTO; } @@ -887,7 +881,7 @@ public class DashboardService { public Pager> getFunctionalCasePage(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); - if (Boolean.FALSE.equals(checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { + if (Boolean.FALSE.equals(projectService.checkModule(projectId, FUNCTIONAL_CASE_MODULE))) { throw new MSException(NO_PROJECT_PERMISSION); } CaseReviewPageRequest reviewRequest = getCaseReviewPageRequest(request); @@ -939,7 +933,7 @@ public class DashboardService { public List getApiUpdatePage(DashboardFrontPageRequest request) { String projectId = request.getProjectIds().getFirst(); - if (Boolean.FALSE.equals(checkModule(projectId, API_TEST_MODULE))) { + if (Boolean.FALSE.equals(projectService.checkModule(projectId, API_TEST_MODULE))) { throw new MSException(NO_PROJECT_PERMISSION); } Long toStartTime = request.getToStartTime(); diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java index 6bcd99db2d..0c70741f07 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectService.java @@ -12,6 +12,7 @@ import io.metersphere.sdk.constants.InternalUserRole; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.CommonBeanFactory; +import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.TestResourcePool; import io.metersphere.system.domain.TestResourcePoolBlob; @@ -328,5 +329,11 @@ public class ProjectService { return extProjectMapper.getResourcePoolOption(projectId, "api_test"); } } + + public Boolean checkModule(String projectId, String module) { + Project project = projectMapper.selectByPrimaryKey(projectId); + List moduleIds = JSON.parseArray(project.getModuleSetting(), String.class); + return moduleIds.contains(module); + } }