From ed3a4fb234515acbea66284a3a597777ce8abe73 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 29 Oct 2024 17:31:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E5=85=A8=E9=83=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE&=E5=85=A8=E9=83=A8=E7=BB=84=E7=BB=87=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E9=80=89=E9=A1=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationTaskHubController.java | 12 ++++++ .../controller/SystemTaskHubController.java | 24 ++++++++++++ .../BaseTaskHubControllerTests.java | 37 +++++++++++++++++++ 3 files changed, 73 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 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); + } + /** * 组织后台任务