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 1b8a521dcb..2bdfbd0d45 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 @@ -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 getOrgProject() { + List projectList = systemProjectService.getProjectOptions(SessionUtils.getCurrentOrganizationId()); + return projectList; + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java index 65d74425a6..75345adf9a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemTaskHubController.java @@ -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 getAllProject() { + List projectList = systemProjectService.getProjectOptions(null); + return projectList; + } + + @GetMapping("/organization/options") + @Operation(summary = "系统-任务中心-获取全部组织下拉选项") + @RequiresPermissions(PermissionConstants.SYSTEM_CASE_TASK_CENTER_READ) + public List getAllOrganization() { + List organizationList = organizationService.getOrganizationOptions(); + return organizationList; + } + } 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 15829944bc..b28aef90f7 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 @@ -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); + } + /** * 组织后台任务