From 472d27f9ac15b7f822d46edc111448ba19cc81d8 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Wed, 9 Oct 2024 10:40:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationTaskHubController.java | 15 ++++++++++++++ .../BaseTaskHubControllerTests.java | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) 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); + } }