From 097ca36387baf8950c10a93f56a72f9eb8315a92 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 24 Oct 2023 19:27:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E9=87=8D=E5=91=BD=E5=90=8D=E6=9E=9A=E4=B8=BE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ModuleType.java => ApplicationScope.java} | 2 +- .../controller/ProjectApplicationController.java | 6 +++--- .../project/service/ProjectService.java | 8 ++++---- .../controller/ProjectControllerTests.java | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) rename backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/{ModuleType.java => ApplicationScope.java} (86%) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ApplicationScope.java similarity index 86% rename from backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleType.java rename to backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ApplicationScope.java index ac55e89e44..61f3c92d56 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ModuleType.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ApplicationScope.java @@ -1,6 +1,6 @@ package io.metersphere.sdk.constants; -public class ModuleType { +public class ApplicationScope { public static final String API_TEST = "api_test"; public static final String UI_TEST = "ui_test"; public static final String LOAD_TEST = "load_test"; diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectApplicationController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectApplicationController.java index 63b296f78a..148834c407 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectApplicationController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectApplicationController.java @@ -5,7 +5,7 @@ import io.metersphere.project.dto.ModuleDTO; import io.metersphere.project.request.ProjectApplicationRequest; import io.metersphere.project.service.ProjectApplicationService; import io.metersphere.project.service.ProjectService; -import io.metersphere.sdk.constants.ModuleType; +import io.metersphere.sdk.constants.ApplicationScope; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.ProjectApplicationType; import io.metersphere.sdk.dto.OptionDTO; @@ -85,7 +85,7 @@ public class ProjectApplicationController { @Operation(summary = "UI测试-获取资源池列表") @RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_UI_READ) public List getUiPoolOptions(@PathVariable String projectId) { - return projectService.getPoolOptions(projectId, ModuleType.UI_TEST); + return projectService.getPoolOptions(projectId, ApplicationScope.UI_TEST); } @@ -152,7 +152,7 @@ public class ProjectApplicationController { @Operation(summary = "接口测试-获取资源池列表") @RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_API_READ) public List getApiPoolOptions(@PathVariable String projectId) { - return projectService.getPoolOptions(projectId, ModuleType.API_TEST); + return projectService.getPoolOptions(projectId, ApplicationScope.API_TEST); } 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 43dea202f8..30cb02cbf2 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 @@ -9,7 +9,7 @@ import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.project.mapper.ProjectTestResourcePoolMapper; import io.metersphere.project.request.ProjectSwitchRequest; import io.metersphere.sdk.constants.InternalUserRole; -import io.metersphere.sdk.constants.ModuleType; +import io.metersphere.sdk.constants.ApplicationScope; import io.metersphere.sdk.dto.OptionDTO; import io.metersphere.sdk.dto.SessionUser; import io.metersphere.sdk.dto.UserDTO; @@ -166,15 +166,15 @@ public class ProjectService { criteria.andIdIn(poolIds).andEnableEqualTo(true).andDeletedEqualTo(false); List testResourcePools = new ArrayList<>(); testResourcePools = switch (type) { - case ModuleType.API_TEST-> { + case ApplicationScope.API_TEST-> { criteria.andApiTestEqualTo(true); yield testResourcePoolMapper.selectByExample(example); } - case ModuleType.UI_TEST -> { + case ApplicationScope.UI_TEST -> { criteria.andUiTestEqualTo(true); yield testResourcePoolMapper.selectByExample(example); } - case ModuleType.LOAD_TEST -> { + case ApplicationScope.LOAD_TEST -> { criteria.andLoadTestEqualTo(true); yield testResourcePoolMapper.selectByExample(example); } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java index 59afa5e431..7f641f0988 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectControllerTests.java @@ -5,7 +5,7 @@ import io.metersphere.project.domain.Project; import io.metersphere.project.domain.ProjectExample; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.project.request.ProjectSwitchRequest; -import io.metersphere.sdk.constants.ModuleType; +import io.metersphere.sdk.constants.ApplicationScope; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.dto.UserDTO; @@ -327,15 +327,15 @@ public class ProjectControllerTests extends BaseTest { @Test @Order(9) public void testGetPoolOptions() throws Exception { - MvcResult mvcResult = this.responseGet(getPoolOptions + ModuleType.API_TEST + "/" + DEFAULT_PROJECT_ID); - mvcResult = this.responseGet(getPoolOptions + ModuleType.UI_TEST + "/" + DEFAULT_PROJECT_ID); - mvcResult = this.responseGet(getPoolOptions + ModuleType.LOAD_TEST + "/" + DEFAULT_PROJECT_ID); + MvcResult mvcResult = this.responseGet(getPoolOptions + ApplicationScope.API_TEST + "/" + DEFAULT_PROJECT_ID); + mvcResult = this.responseGet(getPoolOptions + ApplicationScope.UI_TEST + "/" + DEFAULT_PROJECT_ID); + mvcResult = this.responseGet(getPoolOptions + ApplicationScope.LOAD_TEST + "/" + DEFAULT_PROJECT_ID); mvcResult = this.responseGet(getPoolOptions + "test" + "/" + DEFAULT_PROJECT_ID); - mvcResult = this.responseGet(getPoolOptions + ModuleType.API_TEST + "/" + "projectId"); - mvcResult = this.responseGet(getPoolOptions + ModuleType.UI_TEST + "/" + "projectId"); - mvcResult = this.responseGet(getPoolOptions + ModuleType.LOAD_TEST + "/" + "projectId"); + mvcResult = this.responseGet(getPoolOptions + ApplicationScope.API_TEST + "/" + "projectId"); + mvcResult = this.responseGet(getPoolOptions + ApplicationScope.UI_TEST + "/" + "projectId"); + mvcResult = this.responseGet(getPoolOptions + ApplicationScope.LOAD_TEST + "/" + "projectId"); //项目不存在 - this.responseGet(getPoolOptions + ModuleType.LOAD_TEST + "/" + "projectId20", status().is5xxServerError()); + this.responseGet(getPoolOptions + ApplicationScope.LOAD_TEST + "/" + "projectId20", status().is5xxServerError()); //权限校验 requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, getPoolOptions + "api_test" + "/" + DEFAULT_PROJECT_ID);