From e25ba8a7b3fd1ebec8f9a408c1bd3532a3c2981c Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 21 Oct 2024 14:36:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BB=BB=E5=8A=A1=E6=89=B9=E9=87=8F=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1016480 --user=宋昌昌 任务中心-后台执行任务业务逻辑 https://www.tapd.cn/55049933/s/1594425 --- .../controller/ProjectTaskHubController.java | 16 +++++++++- .../ProjectTaskHubControllerTests.java | 24 +++++++++++++-- .../dml/init_project_exec_task_test.sql | 7 +++-- .../OrganizationTaskHubController.java | 16 ++++++++++ .../controller/SystemTaskHubController.java | 15 ++++++++++ .../system/dto/BatchExecTaskReportDTO.java | 30 +++++++++++++++++++ .../dto/request/BatchExecTaskPageRequest.java | 17 +++++++++++ .../system/mapper/ExtExecTaskItemMapper.java | 10 +++++++ .../system/mapper/ExtExecTaskItemMapper.xml | 8 +++++ .../system/service/BaseTaskHubService.java | 23 ++++++++++++++ .../BaseTaskHubControllerTests.java | 20 +++++++++++-- 11 files changed, 178 insertions(+), 8 deletions(-) create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/BatchExecTaskReportDTO.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/BatchExecTaskPageRequest.java diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java index 760b90e7f3..b91fc6c2a0 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/controller/ProjectTaskHubController.java @@ -1,8 +1,11 @@ package io.metersphere.project.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.dto.BatchExecTaskReportDTO; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; -import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.metersphere.system.dto.taskhub.ResourcePoolOptionsDTO; import io.metersphere.system.dto.taskhub.TaskHubDTO; @@ -17,6 +20,7 @@ import io.metersphere.system.log.constants.OperationLogModule; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.service.BaseTaskHubLogService; import io.metersphere.system.service.BaseTaskHubService; +import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; @@ -24,6 +28,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; 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.*; @@ -181,4 +186,13 @@ public class ProjectTaskHubController { public void updateValue(@PathVariable ScheduleRequest request) { baseTaskHubService.updateCron(request); } + + @PostMapping("/exec-task/batch/page") + @Operation(summary = "项目-任务中心-用例执行任务-批量任务列表") + @RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ) + public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { + Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), + StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); + } } diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java index b018141cb2..6714766dfe 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectTaskHubControllerTests.java @@ -1,8 +1,10 @@ package io.metersphere.project.controller; +import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.metersphere.system.dto.taskhub.request.ScheduleRequest; @@ -18,6 +20,7 @@ import org.springframework.test.web.servlet.MvcResult; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; +import java.util.Map; public class ProjectTaskHubControllerTests extends BaseTest { /** @@ -40,8 +43,9 @@ public class ProjectTaskHubControllerTests extends BaseTest { public static final String PROJECT_SCHEDULE_TASK_BATCH_ENABLE = "/project/task-center/schedule/batch-enable"; public static final String PROJECT_SCHEDULE_TASK_BATCH_DISABLE = "/project/task-center/schedule/batch-disable"; public static final String PROJECT_SCHEDULE_TASK_UPDATE_CRON = "/organization/task-center/schedule/update-cron"; + public static final String PROJECT_BATCH_TASK_PAGE = "/project/task-center/exec-task/batch/page"; - @Test + @Test @Order(1) @Sql(scripts = {"/dml/init_project_exec_task_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void getProjectTaskPage() throws Exception { @@ -166,7 +170,7 @@ public class ProjectTaskHubControllerTests extends BaseTest { * 项目执行任务删除 */ @Test - @Order(5) + @Order(7) public void projectTaskDelete() throws Exception { MvcResult mvcResult = this.requestGetWithOkAndReturn(PROJECT_TASK_DELETE + "4"); // 获取返回值 @@ -177,7 +181,7 @@ public class ProjectTaskHubControllerTests extends BaseTest { } @Test - @Order(6) + @Order(8) public void projectBatchTaskDelete() throws Exception { TableBatchProcessDTO request = new TableBatchProcessDTO(); request.setSelectAll(false); @@ -264,4 +268,18 @@ public class ProjectTaskHubControllerTests extends BaseTest { request.setId("pro_wx_1"); this.requestPost(PROJECT_SCHEDULE_TASK_UPDATE_CRON, request); } + + @Test + @Order(10) + public void getProjectBatchTaskPage() throws Exception { + BatchExecTaskPageRequest request = new BatchExecTaskPageRequest(); + request.setBatchType(ExecTaskType.API_CASE_BATCH.name()); + request.setTaskId("pro_4"); + request.setCurrent(1); + request.setPageSize(10); + this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request); + request.setSort(Map.of("startTime", "asc")); + request.setBatchType(ExecTaskType.API_SCENARIO_BATCH.name()); + this.requestPostWithOk(PROJECT_BATCH_TASK_PAGE, request); + } } diff --git a/backend/services/project-management/src/test/resources/dml/init_project_exec_task_test.sql b/backend/services/project-management/src/test/resources/dml/init_project_exec_task_test.sql index 850202d272..ef7c712978 100644 --- a/backend/services/project-management/src/test/resources/dml/init_project_exec_task_test.sql +++ b/backend/services/project-management/src/test/resources/dml/init_project_exec_task_test.sql @@ -2,12 +2,15 @@ INSERT INTO `exec_task`(`id`, `num`, `task_name`, `status`, `case_count`, `resul VALUES ('pro_1', 1, '测试任务1', 'SUCCESS', 10, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '100001', 1727676089639, 'wx', 1727676089639, 1727676089639), ('pro_2', 2, '测试任务2', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '12345567', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639), - ('pro_3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639); + ('pro_3', 3, '测试任务3', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639), + ('pro_4', 4, '测试任务4', 'SUCCESS', 11, 'SUCCESS', 'FUNCTIONAL', 'API_CASE_BATCH', '100001100001', '11234', 1727676089639, 'wx', 1727676089639, 1727676089639); INSERT INTO `exec_task_item`(`id`, `task_id`, `resource_id`, `resource_name`, `task_origin`, `status`, `result`, `resource_pool_id`, `resource_pool_node`, `resource_type`, `project_id`, `organization_id`, `thread_id`, `start_time`, `end_time`, `executor`) VALUES ('pro_1', 'pro_1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'), - ('pro_2', 'pro_2', '1', '1', '1', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'); + ('pro_2', 'pro_2', '1', '1', '1', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'), + ('pro_4_1', 'pro_4', '1', '1', '1', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'), + ('pro_4_2', 'pro_4', '1', '1', '1', 'SUCCESS', 'SUCCESS', '2', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin'); INSERT INTO `test_resource_pool` (`id`, `name`, `type`, `description`, `enable`, `create_time`, `update_time`, `create_user`, `server_url`, `all_org`, `deleted`) VALUES diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java index 7843bb1a91..173052e396 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationTaskHubController.java @@ -1,7 +1,11 @@ package io.metersphere.system.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; import io.metersphere.sdk.constants.OperationLogConstants; import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.dto.BatchExecTaskReportDTO; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.table.TableBatchProcessDTO; @@ -19,6 +23,7 @@ import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.BaseProjectMapper; import io.metersphere.system.service.BaseTaskHubLogService; import io.metersphere.system.service.BaseTaskHubService; +import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; @@ -26,6 +31,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; 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.*; @@ -196,4 +202,14 @@ public class OrganizationTaskHubController { public void updateValue(@PathVariable ScheduleRequest request) { baseTaskHubService.updateCron(request); } + + @PostMapping("/exec-task/batch/page") + @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") + @RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ) + public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { + Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), + StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); + } + } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java index 85b9e70266..f97de3cd0e 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java @@ -1,7 +1,11 @@ package io.metersphere.system.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.page.PageMethod; import io.metersphere.sdk.constants.OperationLogConstants; import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.system.dto.BatchExecTaskReportDTO; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.metersphere.system.dto.taskhub.*; @@ -15,6 +19,7 @@ import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.security.CheckOwner; import io.metersphere.system.service.BaseTaskHubLogService; import io.metersphere.system.service.BaseTaskHubService; +import io.metersphere.system.utils.PageUtils; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; import io.swagger.v3.oas.annotations.Operation; @@ -22,6 +27,7 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.validation.annotation.Validated; @@ -135,6 +141,15 @@ public class SystemTaskHubController { "/system/task-center/exec-task/batch-delete", OperationLogModule.SETTING_SYSTEM_TASK_CENTER); } + @PostMapping("/exec-task/batch/page") + @Operation(summary = "组织-任务中心-用例执行任务-批量任务列表") + @RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ) + public Pager> batchTaskList(@Validated @RequestBody BatchExecTaskPageRequest request) { + Page page = PageMethod.startPage(request.getCurrent(), request.getPageSize(), + StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "r.start_time desc"); + return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request)); + } + //TODO 系统&组织&项目 任务按钮操作:失败重跑 查看报告 批量失败重跑 diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/BatchExecTaskReportDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/BatchExecTaskReportDTO.java new file mode 100644 index 0000000000..c78af7d13d --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/BatchExecTaskReportDTO.java @@ -0,0 +1,30 @@ +package io.metersphere.system.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @author song-cc-rock + */ +@Data +public class BatchExecTaskReportDTO { + + @Schema(description = "报告ID") + private String id; + @Schema(description = "报告来源 {API, SCENARIO}") + private String source; + @Schema(description = "是否是集成报告") + private Boolean integrated; + @Schema(description = "报告名称") + private String name; + @Schema(description = "报告状态") + private String status; + @Schema(description = "执行结果") + private String execResult; + @Schema(description = "触发方式") + private String triggerMode; + @Schema(description = "创建人") + private String createUser; + @Schema(description = "创建时间") + private Long createTime; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/BatchExecTaskPageRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/BatchExecTaskPageRequest.java new file mode 100644 index 0000000000..ee08996b8a --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/BatchExecTaskPageRequest.java @@ -0,0 +1,17 @@ +package io.metersphere.system.dto.request; + +import io.metersphere.system.dto.sdk.BasePageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @author song-cc-rock + */ +@Data +public class BatchExecTaskPageRequest extends BasePageRequest { + + @Schema(description = "任务ID", requiredMode = Schema.RequiredMode.REQUIRED) + private String taskId; + @Schema(description = "批量任务类型", requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"API_CASE_BATCH", "API_SCENARIO_BATCH"}) + private String batchType; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.java index 9492202401..20f27dc839 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.java @@ -2,6 +2,8 @@ package io.metersphere.system.mapper; import io.metersphere.system.domain.ExecTaskItem; import io.metersphere.system.dto.table.TableBatchProcessDTO; +import io.metersphere.system.dto.BatchExecTaskReportDTO; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.taskhub.TaskHubItemDTO; import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest; import org.apache.ibatis.annotations.Param; @@ -46,4 +48,12 @@ public interface ExtExecTaskItemMapper { List getResourcePoolsByItemIds(@Param("ids") List ids); List getIds(@Param("request") TableBatchProcessDTO request, @Param("organizationId") String organizationId, @Param("projectId") String projectId); + + /** + * 查询批量执行任务报告 + * @param request 请求参数 + * @param tableName 表名 + * @return 执行任务报告集合 + */ + List list(@Param("request") BatchExecTaskPageRequest request, @Param("tableName") String tableName); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml index c609631736..f237a48473 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtExecTaskItemMapper.xml @@ -226,4 +226,12 @@ + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java index fe0f9997a5..c2bf606d7f 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java @@ -16,12 +16,22 @@ import io.metersphere.sdk.constants.*; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.*; import io.metersphere.system.controller.handler.ResultHolder; +import io.metersphere.sdk.constants.ExecStatus; +import io.metersphere.sdk.constants.ExecTaskType; +import io.metersphere.sdk.constants.ResourcePoolTypeEnum; +import io.metersphere.sdk.constants.ResultStatus; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.sdk.util.JSON; +import io.metersphere.sdk.util.LogUtils; +import io.metersphere.sdk.util.SubListUtils; import io.metersphere.system.domain.*; +import io.metersphere.system.dto.BatchExecTaskReportDTO; import io.metersphere.system.dto.ProjectDTO; import io.metersphere.system.dto.builder.LogDTOBuilder; import io.metersphere.system.dto.pool.TestResourceDTO; import io.metersphere.system.dto.pool.TestResourceNodeDTO; import io.metersphere.system.dto.pool.TestResourcePoolReturnDTO; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.table.TableBatchProcessDTO; @@ -838,4 +848,17 @@ public class BaseTaskHubService { throw new RuntimeException(e); } } + + /** + * 查询批量执行任务报告列表 + * @param request 请求参数 + * @return 执行任务报告集合 + */ + public List listBatchTaskReport(BatchExecTaskPageRequest request) { + if (StringUtils.equals(ExecTaskType.API_CASE_BATCH.name(), request.getBatchType())) { + return extExecTaskItemMapper.list(request, "api_report"); + } else { + return extExecTaskItemMapper.list(request, "api_scenario_report"); + } + } } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java index 3ea7c82e65..35bedaba8f 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/BaseTaskHubControllerTests.java @@ -1,11 +1,13 @@ package io.metersphere.system.controller; +import io.metersphere.sdk.constants.ExecTaskType; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.util.JSON; import io.metersphere.system.base.BaseTest; import io.metersphere.system.controller.handler.ResultHolder; import io.metersphere.system.domain.ExecTask; import io.metersphere.system.domain.ExecTaskItem; +import io.metersphere.system.dto.request.BatchExecTaskPageRequest; import io.metersphere.system.dto.sdk.BasePageRequest; import io.metersphere.system.dto.table.TableBatchProcessDTO; import io.metersphere.system.dto.taskhub.request.ScheduleRequest; @@ -62,9 +64,10 @@ public class BaseTaskHubControllerTests extends BaseTest { public static final String SYSTEM_SCHEDULE_TASK_SWITCH = "/system/task-center/schedule/switch/"; public static final String SYSTEM_SCHEDULE_TASK_BATCH_ENABLE = "/system/task-center/schedule/batch-enable"; public static final String SYSTEM_SCHEDULE_TASK_BATCH_DISABLE = "/system/task-center/schedule/batch-disable"; + public static final String SYSTEM_TASK_BATCH_PAGE = "/system/task-center/exec-task/batch/page"; public static final String SYSTEM_SCHEDULE_TASK_UPDATE_CRON = "/system/task-center/schedule/update-cron"; - @Test + @Test @Order(1) @Sql(scripts = {"/dml/init_exec_task_test.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED)) public void getSystemTaskPage() throws Exception { @@ -324,8 +327,9 @@ public class BaseTaskHubControllerTests extends BaseTest { public static final String ORG_SCHEDULE_TASK_BATCH_ENABLE = "/organization/task-center/schedule/batch-enable"; public static final String ORG_SCHEDULE_TASK_BATCH_DISABLE = "/organization/task-center/schedule/batch-disable"; public static final String ORG_SCHEDULE_TASK_UPDATE_CRON = "/organization/task-center/schedule/update-cron"; + public static final String ORG_TASK_BATCH_PAGE = "/organization/task-center/exec-task/batch/page"; - @Test + @Test @Order(20) public void getOrgTaskPage() throws Exception { BasePageRequest request = new BasePageRequest(); @@ -391,6 +395,18 @@ public class BaseTaskHubControllerTests extends BaseTest { Assertions.assertNotNull(resultHolder); } + @Test + @Order(5) + public void getBatchTaskPage() throws Exception { + BatchExecTaskPageRequest request = new BatchExecTaskPageRequest(); + request.setBatchType(ExecTaskType.API_CASE_BATCH.name()); + request.setTaskId("task-id"); + request.setCurrent(1); + request.setPageSize(10); + this.requestPostWithOk(SYSTEM_TASK_BATCH_PAGE, request); + this.requestPostWithOk(ORG_TASK_BATCH_PAGE, request); + } + /** * 组织获取资源池下拉选项