feat(工作台): 提取校验模块开启公共方法

This commit is contained in:
guoyuqi 2024-11-13 09:49:38 +08:00 committed by Craftsman
parent 30ddada8f7
commit 9205f028fd
2 changed files with 13 additions and 12 deletions

View File

@ -558,7 +558,7 @@ public class DashboardService {
public StatisticsDTO projectCaseCount(DashboardFrontPageRequest request) { public StatisticsDTO projectCaseCount(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); String projectId = request.getProjectIds().getFirst();
StatisticsDTO statisticsDTO = new StatisticsDTO(); 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()); statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
return statisticsDTO; return statisticsDTO;
} }
@ -578,12 +578,6 @@ public class DashboardService {
return statisticsDTO; return statisticsDTO;
} }
private Boolean checkModule(String projectId, String module) {
Project project = projectMapper.selectByPrimaryKey(projectId);
List<String> moduleIds = JSON.parseArray(project.getModuleSetting(), String.class);
return moduleIds.contains(module);
}
@NotNull @NotNull
private static List<NameCountDTO> getPassList(Map<String, List<FunctionalCaseStatisticDTO>> reviewStatusMap, List<FunctionalCaseStatisticDTO> statisticListByProjectId) { private static List<NameCountDTO> getPassList(Map<String, List<FunctionalCaseStatisticDTO>> reviewStatusMap, List<FunctionalCaseStatisticDTO> statisticListByProjectId) {
List<NameCountDTO> passList = new ArrayList<>(); List<NameCountDTO> passList = new ArrayList<>();
@ -661,7 +655,7 @@ public class DashboardService {
public StatisticsDTO projectAssociateCaseCount(DashboardFrontPageRequest request) { public StatisticsDTO projectAssociateCaseCount(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); String projectId = request.getProjectIds().getFirst();
StatisticsDTO statisticsDTO = new StatisticsDTO(); 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()); statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
return statisticsDTO; return statisticsDTO;
} }
@ -678,7 +672,7 @@ public class DashboardService {
public OverViewCountDTO projectBugHandleUser(DashboardFrontPageRequest request) { public OverViewCountDTO projectBugHandleUser(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); 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<>()); return new OverViewCountDTO(null, new ArrayList<>(), new ArrayList<>());
Long toStartTime = request.getToStartTime(); Long toStartTime = request.getToStartTime();
Long toEndTime = request.getToEndTime(); Long toEndTime = request.getToEndTime();
@ -811,7 +805,7 @@ public class DashboardService {
public StatisticsDTO projectReviewCaseCount(DashboardFrontPageRequest request) { public StatisticsDTO projectReviewCaseCount(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); String projectId = request.getProjectIds().getFirst();
StatisticsDTO statisticsDTO = new StatisticsDTO(); 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()); statisticsDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
return statisticsDTO; return statisticsDTO;
} }
@ -887,7 +881,7 @@ public class DashboardService {
public Pager<List<CaseReviewDTO>> getFunctionalCasePage(DashboardFrontPageRequest request) { public Pager<List<CaseReviewDTO>> getFunctionalCasePage(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); 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); throw new MSException(NO_PROJECT_PERMISSION);
} }
CaseReviewPageRequest reviewRequest = getCaseReviewPageRequest(request); CaseReviewPageRequest reviewRequest = getCaseReviewPageRequest(request);
@ -939,7 +933,7 @@ public class DashboardService {
public List<ApiDefinitionUpdateDTO> getApiUpdatePage(DashboardFrontPageRequest request) { public List<ApiDefinitionUpdateDTO> getApiUpdatePage(DashboardFrontPageRequest request) {
String projectId = request.getProjectIds().getFirst(); 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); throw new MSException(NO_PROJECT_PERMISSION);
} }
Long toStartTime = request.getToStartTime(); Long toStartTime = request.getToStartTime();

View File

@ -12,6 +12,7 @@ import io.metersphere.sdk.constants.InternalUserRole;
import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.CommonBeanFactory;
import io.metersphere.sdk.util.JSON;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.TestResourcePool; import io.metersphere.system.domain.TestResourcePool;
import io.metersphere.system.domain.TestResourcePoolBlob; import io.metersphere.system.domain.TestResourcePoolBlob;
@ -328,5 +329,11 @@ public class ProjectService {
return extProjectMapper.getResourcePoolOption(projectId, "api_test"); return extProjectMapper.getResourcePoolOption(projectId, "api_test");
} }
} }
public Boolean checkModule(String projectId, String module) {
Project project = projectMapper.selectByPrimaryKey(projectId);
List<String> moduleIds = JSON.parseArray(project.getModuleSetting(), String.class);
return moduleIds.contains(module);
}
} }