diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java index 3d8332b856..7bf3801b83 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java @@ -145,6 +145,8 @@ public class PermissionConstants { public static final String PROJECT_APPLICATION_TEST_PLAN_UPDATE = "PROJECT_APPLICATION_TEST_PLAN:UPDATE"; public static final String PROJECT_APPLICATION_UI_READ = "PROJECT_APPLICATION_UI:READ"; public static final String PROJECT_APPLICATION_UI_UPDATE = "PROJECT_APPLICATION_UI:UPDATE"; + public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_READ = "PROJECT_APPLICATION_PERFORMANCE_TEST:READ"; + public static final String PROJECT_APPLICATION_PERFORMANCE_TEST_UPDATE = "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE"; /*------ end: PROJECT_APPLICATION ------*/ public static final String PROJECT_BASE_INFO_READ = "PROJECT_BASE_INFO:READ"; } diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ProjectApplicationType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ProjectApplicationType.java index 0942210b33..12d8624efc 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ProjectApplicationType.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/ProjectApplicationType.java @@ -32,6 +32,21 @@ public enum ProjectApplicationType { APPLICATION_SHARE_UI_REPORT, + //性能测试 + /** + * 性能测试报告保留范围 value + */ + APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT, + /** + * 性能测试报告有效期 value + */ + APPLICATION_SHARE_PERFORMANCE_TEST_REPORT, + /** + * 性能测试脚本审核人 + */ + APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER, + + //缺陷管理 /** * 同步缺陷 标识 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties index a9dbe924ac..d6197ad787 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_en_US.properties @@ -109,5 +109,7 @@ permission.project_application_test_plan.read=Test plan read permission.project_application_test_plan.update=Test plan update permission.project_application_ui.read=UI test read permission.project_application_ui.update=UI test update +permission.project_application_performance_test.read=Performance test read +permission.project_application_performance_test.update=Performance test update permission.project_base_info.name=Project base info permission.project_log.name=Operation log diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties index 611b6b0820..cce9f49d39 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_CN.properties @@ -109,5 +109,7 @@ permission.project_application_test_plan.read=测试计划-查询 permission.project_application_test_plan.update=测试计划-编辑 permission.project_application_ui.read=UI测试-查询 permission.project_application_ui.update=UI测试-编辑 +permission.project_application_performance_test.read=性能测试-查询 +permission.project_application_performance_test.update=性能测试-编辑 permission.project_base_info.name=基本信息 permission.project_log.name=日志 diff --git a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties index ef32a47035..d56d0550e6 100644 --- a/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/project_zh_TW.properties @@ -109,5 +109,7 @@ permission.project_application_test_plan.read=測試計劃-查詢 permission.project_application_test_plan.update=測試計劃-編輯 permission.project_application_ui.read=UI測試-查詢 permission.project_application_ui.update=UI測試-編輯 +permission.project_application_performance_test.read=性能測試-查詢 +permission.project_application_performance_test.update=性能測試-編輯 permission.project_base_info.name=基本信息 permission.project_log.name=日誌 \ No newline at end of file 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 f4d5f4536b..27b4c46eb4 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 @@ -6,10 +6,14 @@ import io.metersphere.project.service.ProjectApplicationService; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogType; +import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.User; +import io.metersphere.system.service.UserService; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -23,7 +27,8 @@ import java.util.List; public class ProjectApplicationController { @Resource private ProjectApplicationService projectApplicationService; - + @Resource + private UserService userService; /** * ==========测试计划========== @@ -63,4 +68,31 @@ public class ProjectApplicationController { public List getUI(@Validated @RequestBody ProjectApplicationRequest request) { return projectApplicationService.get(request); } + + + /** + * ==========性能测试========== + */ + + @PostMapping("/update/performance-test") + @Operation(summary = "应用设置-性能测试-配置") + @RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_UPDATE) + @Log(type = OperationLogType.UPDATE, expression = "#msClass.updatePerformanceLog(#application)", msClass = ProjectApplicationService.class) + public ProjectApplication updatePerformanceTest(@Validated({Updated.class}) @RequestBody ProjectApplication application) { + return projectApplicationService.update(application); + } + + @PostMapping("/performance-test") + @Operation(summary = "应用设置-性能测试-获取配置") + @RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_READ) + public List getPerformanceTest(@Validated @RequestBody ProjectApplicationRequest request) { + return projectApplicationService.get(request); + } + + @GetMapping("/performance-test/user/{projectId}") + @Operation(summary = "应用设置-性能测试-获取审核人") + @RequiresPermissions(PermissionConstants.PROJECT_APPLICATION_PERFORMANCE_TEST_READ) + public List getCheckUser(@PathVariable String projectId) { + return projectApplicationService.getProjectUserList(StringUtils.defaultIfBlank(projectId, SessionUtils.getCurrentProjectId())); + } } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.java b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.java index 960f4475d2..2fd282ebe1 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.java @@ -17,4 +17,11 @@ public interface ExtProjectUserRoleMapper { * @return 项目成员列表 */ List listProjectRoleMember(@Param("request") ProjectUserRoleMemberRequest request); + + /** + * 根据项目id获取 项目成员 + * @param sourceId + * @return + */ + List getProjectUserList(@Param("sourceId") String sourceId); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.xml b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.xml index d4fefc113a..f65ac725eb 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.xml +++ b/backend/services/project-management/src/main/java/io/metersphere/project/mapper/ExtProjectUserRoleMapper.xml @@ -10,4 +10,16 @@ and u.name like concat('%', #{request.keyword}, '%') + + \ No newline at end of file diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java index ebacc5b3e1..ec43242d7d 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectApplicationService.java @@ -3,6 +3,7 @@ package io.metersphere.project.service; import io.metersphere.project.domain.ProjectApplication; import io.metersphere.project.domain.ProjectApplicationExample; import io.metersphere.project.job.CleanUpReportJob; +import io.metersphere.project.mapper.ExtProjectUserRoleMapper; import io.metersphere.project.mapper.ProjectApplicationMapper; import io.metersphere.project.request.ProjectApplicationRequest; import io.metersphere.sdk.constants.OperationLogConstants; @@ -15,6 +16,8 @@ import io.metersphere.sdk.sechedule.BaseScheduleService; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.SessionUtils; import io.metersphere.system.domain.Schedule; +import io.metersphere.system.domain.User; +import io.metersphere.system.mapper.ExtUserMapper; import jakarta.annotation.Resource; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; @@ -35,6 +38,9 @@ public class ProjectApplicationService { @Resource private BaseScheduleService baseScheduleService; + @Resource + private ExtProjectUserRoleMapper extProjectUserRoleMapper; + /** * 更新配置信息 @@ -67,8 +73,9 @@ public class ProjectApplicationService { String type = application.getType(); //TODO 自定义id配置 &其他配置 if (StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_TEST_PLAN_REPORT.name()) - || StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name())) { - //清除 测试计划/UI 报告 定时任务 + || StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name()) + || StringUtils.equals(type, ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name())) { + //清除 测试计划/UI测试/性能测试 报告 定时任务 this.doHandleSchedule(application); } } @@ -110,6 +117,7 @@ public class ProjectApplicationService { /** * 获取配置信息 + * * @param request * @return */ @@ -124,6 +132,11 @@ public class ProjectApplicationService { } + public List getProjectUserList(String projectId) { + return extProjectUserRoleMapper.getProjectUserList(projectId); + } + + /** * 测试计划 日志 * @@ -145,6 +158,15 @@ public class ProjectApplicationService { return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "UI配置"); } + /** + * 性能测试 日志 + * + * @param application + * @return + */ + public LogDTO updatePerformanceLog(ProjectApplication application) { + return delLog(application, OperationLogModule.PROJECT_PROJECT_MANAGER, "性能测试配置"); + } private LogDTO delLog(ProjectApplication application, String module, String content) { ProjectApplicationExample example = new ProjectApplicationExample(); diff --git a/backend/services/project-management/src/main/resources/permission.json b/backend/services/project-management/src/main/resources/permission.json index c5d242c0e0..10e85232bc 100644 --- a/backend/services/project-management/src/main/resources/permission.json +++ b/backend/services/project-management/src/main/resources/permission.json @@ -143,6 +143,14 @@ { "id": "PROJECT_APPLICATION_UI:UPDATE", "name": "permission.project_application_ui.update" + }, + { + "id": "PROJECT_APPLICATION_PERFORMANCE_TEST:READ", + "name": "permission.project_application_performance_test.read" + }, + { + "id": "PROJECT_APPLICATION_PERFORMANCE_TEST:UPDATE", + "name": "permission.project_application_performance_test.update" } ] }, diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java index 30c300ea32..cf4a77e4f8 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectApplicationControllerTests.java @@ -77,7 +77,6 @@ public class ProjectApplicationControllerTests extends BaseTest { */ - /** * ==========UI测试 start========== */ @@ -90,7 +89,6 @@ public class ProjectApplicationControllerTests extends BaseTest { @Test @Order(4) public void testUiClean() throws Exception { - this.testGetTestPlan(); //新增 ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_CLEAN_UI_REPORT.name(), TIME_TYPE_VALUE); this.requestPost(UI_UPDATE_URL, request); @@ -131,6 +129,71 @@ public class ProjectApplicationControllerTests extends BaseTest { */ + /** + * ==========性能测试 start========== + */ + // 性能测试 + public static final String PERFORMANCE_UPDATE_URL = "/project/application/update/performance-test"; + //获取配置 + public static final String GET_PERFORMANCE_URL = "/project/application/performance-test"; + //获取脚本审核人 + public static final String GET_USER_URL = "/project/application/performance-test/user"; + + //应用配置 - UI测试 - 清理报告配置 + @Test + @Order(7) + public void testPerformanceClean() throws Exception { + //新增 + ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name(), TIME_TYPE_VALUE); + this.requestPost(PERFORMANCE_UPDATE_URL, request); + //更新 + request.setTypeValue("4M"); + this.requestPost(PERFORMANCE_UPDATE_URL, request); + // @@异常参数校验 + updatedGroupParamValidateTest(ProjectApplicationDefinition.class, PERFORMANCE_UPDATE_URL); + + } + + //应用管理 - UI测试 - 分享报告配置 + @Test + @Order(8) + public void testPerformanceShare() throws Exception { + //新增 + ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_SHARE_PERFORMANCE_TEST_REPORT.name(), TIME_TYPE_VALUE); + this.requestPost(PERFORMANCE_UPDATE_URL, request); + //更新 + request.setTypeValue("5M"); + this.requestPost(PERFORMANCE_UPDATE_URL, request); + } + + //应用管理 - UI测试 - 脚本审核 + @Test + @Order(9) + public void testPerformanceReviewer() throws Exception { + //新增 + ProjectApplication request = creatRequest(ProjectApplicationType.APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER.name(), "admin"); + this.requestPost(PERFORMANCE_UPDATE_URL, request); + } + + //应用管理 - UI测试 - 获取配置 + @Test + @Order(10) + public void testGetPerformance() throws Exception { + //清理报告 + 分享报告 + List types = Arrays.asList(ProjectApplicationType.APPLICATION_CLEAN_PERFORMANCE_TEST_REPORT.name(), ProjectApplicationType.APPLICATION_SHARE_PERFORMANCE_TEST_REPORT.name(), ProjectApplicationType.APPLICATION_PERFORMANCE_TEST_SCRIPT_REVIEWER.name()); + ProjectApplicationRequest request = this.getRequest(types); + this.requestPostWithOkAndReturn(GET_PERFORMANCE_URL, request); + // @@异常参数校验 + updatedGroupParamValidateTest(ProjectApplicationRequestDefinition.class, GET_PERFORMANCE_URL); + } + + @Test + @Order(11) + public void testGetUser() throws Exception { + this.requestGetWithOkAndReturn(GET_USER_URL + "/default-project-2"); + } + + private ProjectApplicationRequest getRequest(List types) { ProjectApplicationRequest request = new ProjectApplicationRequest(); request.setProjectId(PROJECT_ID);