feat(任务中心): 组织&项目任务中心执行任务详情列表查询初版

This commit is contained in:
WangXu10 2024-10-10 13:51:37 +08:00 committed by Craftsman
parent 7d585c06ee
commit 9ccdcb2fde
6 changed files with 70 additions and 2 deletions

View File

@ -4,7 +4,9 @@ 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.TaskHubItemDTO;
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
import io.metersphere.system.service.BaseTaskHubService;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
@ -41,4 +43,12 @@ public class ProjectTaskHubController {
public Pager<List<TaskHubScheduleDTO>> scheduleList(@Validated @RequestBody BasePageRequest request) {
return baseTaskHubService.getScheduleTaskList(request, List.of(SessionUtils.getCurrentProjectId()));
}
@PostMapping("/exec-task/item/page")
@Operation(summary = "项目-任务中心-用例执行任务详情列表")
@RequiresPermissions(PermissionConstants.PROJECT_CASE_TASK_CENTER_READ)
public Pager<List<TaskHubItemDTO>> itemPageList(@Validated @RequestBody TaskHubItemRequest request) {
return baseTaskHubService.getCaseTaskItemList(request, null, SessionUtils.getCurrentProjectId());
}
}

View File

@ -4,6 +4,7 @@ import io.metersphere.sdk.util.JSON;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.dto.sdk.BasePageRequest;
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@ -19,6 +20,7 @@ public class ProjectTaskHubControllerTests extends BaseTest {
*/
public static final String PROJECT_TASK_PAGE = "/project/task-center/exec-task/page";
public static final String PROJECT_SCHEDULE_TASK_PAGE = "/project/task-center/schedule/page";
public static final String PROJECT_TASK_ITEM_PAGE = "/project/task-center/exec-task/item/page";
@Test
@Order(1)
@ -54,4 +56,24 @@ public class ProjectTaskHubControllerTests extends BaseTest {
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
/**
* 执行任务详情列表
*/
@Test
@Order(3)
public void getProjectTaskItemPage() throws Exception {
TaskHubItemRequest request = new TaskHubItemRequest();
request.setTaskId("pro_1");
this.requestPost(PROJECT_TASK_ITEM_PAGE, request);
request.setCurrent(1);
request.setPageSize(10);
MvcResult mvcResult = this.requestPostWithOkAndReturn(PROJECT_TASK_ITEM_PAGE, request);
// 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
}

View File

@ -3,3 +3,6 @@ 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);
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');

View File

@ -4,7 +4,9 @@ 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.TaskHubItemDTO;
import io.metersphere.system.dto.taskhub.TaskHubScheduleDTO;
import io.metersphere.system.dto.taskhub.request.TaskHubItemRequest;
import io.metersphere.system.mapper.BaseProjectMapper;
import io.metersphere.system.service.BaseTaskHubService;
import io.metersphere.system.utils.Pager;
@ -47,4 +49,12 @@ public class OrganizationTaskHubController {
List<String> projectIds = projectList.stream().map(OptionDTO::getId).toList();
return baseTaskHubService.getScheduleTaskList(request, projectIds);
}
@PostMapping("/exec-task/item/page")
@Operation(summary = "组织-任务中心-用例执行任务详情列表")
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ)
public Pager<List<TaskHubItemDTO>> itemPageList(@Validated @RequestBody TaskHubItemRequest request) {
return baseTaskHubService.getCaseTaskItemList(request, SessionUtils.getCurrentOrganizationId(), null);
}
}

View File

@ -72,7 +72,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
/**
* 系统后台任务
* 系统任务详情
*/
@Test
@Order(3)
@ -96,6 +96,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";
public static final String ORG_TASK_ITEM_PAGE = "/organization/task-center/exec-task/item/page";
@Test
@Order(20)
@ -132,6 +133,28 @@ public class BaseTaskHubControllerTests extends BaseTest {
}
/**
* 组织任务详情
*/
@Test
@Order(3)
public void getOrgTaskItemPage() throws Exception {
TaskHubItemRequest request = new TaskHubItemRequest();
request.setTaskId("1");
this.requestPost(ORG_TASK_ITEM_PAGE, request);
request.setCurrent(1);
request.setPageSize(10);
MvcResult mvcResult = this.requestPostWithOkAndReturn(ORG_TASK_ITEM_PAGE, request);
// 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
@Test
@Order(21)
public void testInsert() throws Exception {

View File

@ -18,4 +18,4 @@ VALUES
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 ('1', '1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '1', '1', '1', NULL, NULL, 'admin');
VALUES ('1', '1', '1', '1', '1', 'SUCCESS', 'SUCCESS', '1', '1', 'API_CASE', '100001100001', '100001', '1', NULL, NULL, 'admin');