feat(任务中心): 组织任务中心后台任务列表查询

This commit is contained in:
WangXu10 2024-10-09 10:40:16 +08:00 committed by Craftsman
parent 1a41bcae3f
commit 472d27f9ac
2 changed files with 35 additions and 0 deletions

View File

@ -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<List<TaskHubDTO>> 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<List<TaskHubScheduleDTO>> scheduleList(@Validated @RequestBody BasePageRequest request) {
List<OptionDTO> projectList = baseProjectMapper.getProjectOptionsByOrgId(SessionUtils.getCurrentOrganizationId());
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
return baseTaskHubService.getScheduleTaskList(request, projectIds);
}
}

View File

@ -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);
}
}