diff --git a/backend/framework/domain/src/main/resources/migration/3.0.1/ddl/V3.0.1_2__ga_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.0.1/ddl/V3.0.1_2__ga_ddl.sql index 2232347e50..0de1d89ae1 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.1/ddl/V3.0.1_2__ga_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.1/ddl/V3.0.1_2__ga_ddl.sql @@ -184,7 +184,7 @@ CREATE TABLE IF NOT EXISTS test_plan_report_api_case( `api_case_id` VARCHAR(50) NOT NULL COMMENT '接口用例ID' , `api_case_num` BIGINT NOT NULL COMMENT '接口用例业务ID' , `api_case_name` VARCHAR(255) NOT NULL COMMENT '接口用例名称' , - `api_case_module` VARCHAR(255) COMMENT '接口用例所属模块' , + `api_case_module` VARCHAR(500) COMMENT '接口用例所属模块', `api_case_priority` VARCHAR(255) COMMENT '接口用例等级' , `api_case_execute_user` VARCHAR(50) COMMENT '接口用例执行人' , `api_case_execute_result` VARCHAR(50) COMMENT '接口用例执行结果' , @@ -206,7 +206,7 @@ CREATE TABLE IF NOT EXISTS test_plan_report_api_scenario( `api_scenario_id` VARCHAR(50) NOT NULL COMMENT '场景用例ID' , `api_scenario_num` BIGINT NOT NULL COMMENT '场景用例业务ID' , `api_scenario_name` VARCHAR(255) NOT NULL COMMENT '场景用例名称' , - `api_scenario_module` VARCHAR(255) COMMENT '场景用例所属模块' , + `api_scenario_module` VARCHAR(500) COMMENT '场景用例所属模块', `api_scenario_priority` VARCHAR(255) COMMENT '场景用例等级' , `api_scenario_execute_user` VARCHAR(50) COMMENT '场景用例执行人' , `api_scenario_execute_result` VARCHAR(50) COMMENT '场景用例执行结果' , diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/utils/ServiceUtils.java b/backend/services/system-setting/src/main/java/io/metersphere/system/utils/ServiceUtils.java index 06533795e2..4ec9cc0dfb 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/utils/ServiceUtils.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/utils/ServiceUtils.java @@ -116,4 +116,13 @@ public class ServiceUtils { } throw new MSException(MsHttpResultCode.VALIDATE_FAILED, tips.toString()); } + + public static String compressName(String name, int maxSize) { + String newName = name; + // 限制名称长度 (数据库里最大的长度是255,这里判断超过250时截取到200附近) + if (newName.length() > maxSize) { + newName = newName.substring(0, maxSize - 3) + "..."; + } + return newName; + } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanExecuteController.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanExecuteController.java index 246d464f5b..f23f02810a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanExecuteController.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/controller/TestPlanExecuteController.java @@ -45,9 +45,9 @@ public class TestPlanExecuteController { } @PostMapping("/batch") - @Operation(summary = "测试计划-开始自行") + @Operation(summary = "测试计划-批量执行") @RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE) - @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") + @CheckOwner(resourceId = "#request.getExecuteIds()", resourceType = "test_plan") @Log(type = OperationLogType.EXECUTE, expression = "#msClass.batchExecuteLog(#request)", msClass = TestPlanLogService.class) public void startExecute(@Validated @RequestBody TestPlanBatchExecuteRequest request) { testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN)); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 81fb37140b..c8bfb94eca 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -31,6 +31,7 @@ import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.service.SimpleUserService; import io.metersphere.system.uid.IDGenerator; +import io.metersphere.system.utils.ServiceUtils; import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -385,6 +386,8 @@ public class TestPlanReportService { reportApiCase.setTestPlanReportId(report.getId()); reportApiCase.setApiCaseModule(moduleParam.getApiModuleMap().getOrDefault(reportApiCase.getApiCaseModule(), ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiCase.getApiCaseModule())); + //根据不超过数据库字段最大长度压缩模块名 + reportApiCase.setApiCaseModule(ServiceUtils.compressName(reportApiCase.getApiCaseModule(), 450)); if (!genParam.getUseManual()) { // 接口执行时才更新结果 reportApiCase.setApiCaseExecuteResult(null); @@ -405,6 +408,8 @@ public class TestPlanReportService { reportApiScenario.setTestPlanReportId(report.getId()); reportApiScenario.setApiScenarioModule(moduleParam.getScenarioModuleMap().getOrDefault(reportApiScenario.getApiScenarioModule(), ModuleTreeUtils.MODULE_PATH_PREFIX + reportApiScenario.getApiScenarioModule())); + //根据不超过数据库字段最大长度压缩模块名 + reportApiScenario.setApiScenarioModule(ServiceUtils.compressName(reportApiScenario.getApiScenarioModule(), 450)); if (!genParam.getUseManual()) { // 接口执行时才更新结果 reportApiScenario.setApiScenarioExecuteResult(null);