feat(任务中心): 新增查询全部项目&全部组织下拉选项接口

This commit is contained in:
WangXu10 2024-10-29 17:31:45 +08:00 committed by Craftsman
parent ad97ee0ef9
commit ed3a4fb234
3 changed files with 73 additions and 0 deletions

View File

@ -5,6 +5,7 @@ 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.OrganizationProjectOptionsDTO;
import io.metersphere.system.dto.request.BatchExecTaskPageRequest;
import io.metersphere.system.dto.sdk.BasePageRequest;
import io.metersphere.system.dto.sdk.OptionDTO;
@ -23,6 +24,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.service.SystemProjectService;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
@ -50,6 +52,8 @@ public class OrganizationTaskHubController {
BaseProjectMapper baseProjectMapper;
@Resource
private BaseTaskHubLogService baseTaskHubLogService;
@Resource
private SystemProjectService systemProjectService;
@PostMapping("/exec-task/page")
@Operation(summary = "组织-任务中心-执行任务列表")
@ -215,4 +219,12 @@ public class OrganizationTaskHubController {
return PageUtils.setPageInfo(page, baseTaskHubService.listBatchTaskReport(request));
}
@GetMapping("/project/options")
@Operation(summary = "系统-任务中心-获取组织下全部项目下拉选项")
@RequiresPermissions(PermissionConstants.ORGANIZATION_CASE_TASK_CENTER_READ)
public List<OrganizationProjectOptionsDTO> getOrgProject() {
List<OrganizationProjectOptionsDTO> projectList = systemProjectService.getProjectOptions(SessionUtils.getCurrentOrganizationId());
return projectList;
}
}

View File

@ -5,6 +5,7 @@ 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.OrganizationProjectOptionsDTO;
import io.metersphere.system.dto.request.BatchExecTaskPageRequest;
import io.metersphere.system.dto.sdk.BasePageRequest;
import io.metersphere.system.dto.table.TableBatchProcessDTO;
@ -18,6 +19,8 @@ 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.service.OrganizationService;
import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
@ -44,6 +47,10 @@ public class SystemTaskHubController {
private BaseTaskHubService baseTaskHubService;
@Resource
private BaseTaskHubLogService baseTaskHubLogService;
@Resource
private SystemProjectService systemProjectService;
@Resource
private OrganizationService organizationService;
@PostMapping("/exec-task/page")
@Operation(summary = "系统-任务中心-执行任务列表")
@ -212,4 +219,21 @@ public class SystemTaskHubController {
baseTaskHubService.updateCron(request, SessionUtils.getUserId(), "/system/task-center/schedule/update-cron", OperationLogModule.SETTING_SYSTEM_TASK_CENTER);
}
@GetMapping("/project/options")
@Operation(summary = "系统-任务中心-获取全部项目下拉选项")
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
public List<OrganizationProjectOptionsDTO> getAllProject() {
List<OrganizationProjectOptionsDTO> projectList = systemProjectService.getProjectOptions(null);
return projectList;
}
@GetMapping("/organization/options")
@Operation(summary = "系统-任务中心-获取全部组织下拉选项")
@RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ)
public List<OrganizationProjectOptionsDTO> getAllOrganization() {
List<OrganizationProjectOptionsDTO> organizationList = organizationService.getOrganizationOptions();
return organizationList;
}
}

View File

@ -69,6 +69,8 @@ public class BaseTaskHubControllerTests extends BaseTest {
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";
public static final String SYSTEM_PROJECT_OPTIONS = "/system/task-center/project/options";
public static final String SYSTEM_ORGANIZATION_OPTIONS = "/system/task-center/organization/options";
@Test
@Order(1)
@ -87,6 +89,29 @@ public class BaseTaskHubControllerTests extends BaseTest {
}
@Test
@Order(3)
public void getProjectOptions() throws Exception {
MvcResult mvcResult = this.requestGetWithOkAndReturn(SYSTEM_PROJECT_OPTIONS);
// 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
@Test
@Order(3)
public void getOrganizationOptions() throws Exception {
MvcResult mvcResult = this.requestGetWithOkAndReturn(SYSTEM_ORGANIZATION_OPTIONS);
// 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
/**
* 系统后台任务
*/
@ -336,6 +361,7 @@ public class BaseTaskHubControllerTests extends BaseTest {
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";
public static final String ORG_PROJECT_OPTIONS = "/organization/task-center/project/options";
@Test
@Order(20)
@ -352,6 +378,17 @@ public class BaseTaskHubControllerTests extends BaseTest {
Assertions.assertNotNull(resultHolder);
}
@Test
@Order(20)
public void getOrgProjectOptions() throws Exception {
MvcResult mvcResult = this.requestGetWithOkAndReturn(ORG_PROJECT_OPTIONS);
// 获取返回值
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
}
/**
* 组织后台任务