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 91b2f3f6d6..17d06333bf 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 @@ -2,7 +2,10 @@ package io.metersphere.system.controller; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.system.dto.sdk.BasePageRequest; +import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.taskhub.TaskHubDTO; +import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO; +import io.metersphere.system.mapper.BaseProjectMapper; import io.metersphere.system.service.BaseTaskHubService; import io.metersphere.system.utils.Pager; import io.metersphere.system.utils.SessionUtils; @@ -25,6 +28,8 @@ public class OrganizationTaskHubController { @Resource private BaseTaskHubService baseTaskHubService; + @Resource + BaseProjectMapper baseProjectMapper; @PostMapping("/exec-task/page") @Operation(summary = "组织-任务中心-执行任务列表") @@ -32,4 +37,14 @@ public class OrganizationTaskHubController { public Pager> projectList(@Validated @RequestBody BasePageRequest request) { return baseTaskHubService.getTaskList(request, SessionUtils.getCurrentOrganizationId(), null); } + + + @PostMapping("/schedule/page") + @Operation(summary = "组织-任务中心-后台执行任务列表") + @RequiresPermissions(PermissionConstants.SYSTEM_SCHEDULE_TASK_CENTER_READ) + public Pager> scheduleList(@Validated @RequestBody BasePageRequest request) { + List projectList = baseProjectMapper.getProjectOptionsByOrgId(SessionUtils.getCurrentOrganizationId()); + List projectIds = projectList.stream().map(OptionDTO::getId).toList(); + return baseTaskHubService.getScheduleTaskList(request, projectIds); + } } 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 84743baa27..e372e12558 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 @@ -64,6 +64,7 @@ public class BaseTaskHubControllerTests extends BaseTest { * 组织任务中心测试用例 */ public static final String ORG_TASK_PAGE = "/organization/task-center/exec-task/page"; + public static final String ORG_SCHEDULE_TASK_PAGE = "/organization/task-center/schedule/page"; @Test @Order(20) @@ -79,4 +80,23 @@ public class BaseTaskHubControllerTests extends BaseTest { // 返回请求正常 Assertions.assertNotNull(resultHolder); } + + + /** + * 组织后台任务 + */ + @Test + @Order(2) + public void getOrgSchedulePage() throws Exception { + BasePageRequest request = new BasePageRequest(); + this.requestPost(ORG_SCHEDULE_TASK_PAGE, request); + request.setCurrent(1); + request.setPageSize(10); + MvcResult mvcResult = this.requestPostWithOkAndReturn(ORG_SCHEDULE_TASK_PAGE, request); + // 获取返回值 + String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); + // 返回请求正常 + Assertions.assertNotNull(resultHolder); + } }