From bb9c7979d46f499115e4578a259dd83b926624cc Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 22 Jun 2021 20:31:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=A6=96=E9=A1=B5=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APITestController.java | 32 +++--------- .../base/mapper/ext/ExtScheduleMapper.java | 5 +- .../base/mapper/ext/ExtScheduleMapper.xml | 19 +++++-- .../metersphere/service/ScheduleService.java | 5 +- .../homepage/components/RunningTaskList.vue | 49 ++++++++++++++++--- frontend/src/i18n/en-US.js | 2 +- frontend/src/i18n/zh-CN.js | 2 +- frontend/src/i18n/zh-TW.js | 2 +- 8 files changed, 74 insertions(+), 42 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index a49da6aca0..36c740f874 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -16,19 +16,17 @@ import io.metersphere.api.dto.scenario.environment.EnvironmentConfig; import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter; import io.metersphere.api.service.*; import io.metersphere.base.domain.*; -import io.metersphere.commons.constants.RoleConstants; -import io.metersphere.commons.constants.ScheduleGroup; -import io.metersphere.commons.utils.*; +import io.metersphere.commons.utils.CronUtils; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.controller.request.ScheduleRequest; import io.metersphere.dto.ScheduleDao; -import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.CheckPermissionService; import io.metersphere.service.ScheduleService; -import org.apache.commons.lang3.StringUtils; import org.apache.jorphan.collections.HashTree; -import org.apache.shiro.authz.annotation.Logical; -import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -59,12 +57,6 @@ public class APITestController { @Resource private ScheduleService scheduleService; @Resource - private APIReportService apiReportService; - @Resource - private PerformanceTestService performanceTestService; - @Resource - private CheckPermissionService checkPermissionService; - @Resource private HistoricalDataUpgradeService historicalDataUpgradeService; @Resource private ApiTestEnvironmentService environmentService; @@ -354,17 +346,9 @@ public class APITestController { return returnList; } - @GetMapping("/runningTask/{projectID}/{callFrom}") - public List runningTask(@PathVariable String projectID, @PathVariable String callFrom) { - List typeFilter = new ArrayList<>(); - if (StringUtils.equals(callFrom, "api_test")) { // 接口测试首页显示的运行中定时任务,只要这3种,不需要 性能测试、api_test(旧版) - typeFilter.add(ScheduleGroup.API_SCENARIO_TEST.name()); - typeFilter.add(ScheduleGroup.SWAGGER_IMPORT.name()); - typeFilter.add(ScheduleGroup.TEST_PLAN_TEST.name()); - } else if (StringUtils.equals(callFrom, "track_home")) { // 测试跟踪首页只显示测试计划的定时任务 - typeFilter.add(ScheduleGroup.TEST_PLAN_TEST.name()); - } - List resultList = scheduleService.findRunningTaskInfoByProjectID(projectID, typeFilter); + @PostMapping("/runningTask/{projectID}") + public List runningTask(@PathVariable String projectID,@RequestBody BaseQueryRequest request) { + List resultList = scheduleService.findRunningTaskInfoByProjectID(projectID, request); int dataIndex = 1; for (TaskInfoResult taskInfo : resultList) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java index 36857bac0e..04d56c9ccd 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.java @@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.api.dto.datacount.response.TaskInfoResult; import io.metersphere.api.dto.definition.ApiSwaggerUrlDTO; +import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.dto.ScheduleDao; import org.apache.ibatis.annotations.Param; @@ -15,7 +16,7 @@ public interface ExtScheduleMapper { long countTaskByProjectIdAndCreateTimeRange(@Param("projectId")String projectId, @Param("startTime") long startTime, @Param("endTime") long endTime); - List findRunningTaskInfoByProjectID(@Param("projectId") String workspaceID, @Param("types") List typeFilter); + List findRunningTaskInfoByProjectID(@Param("projectId") String workspaceID, @Param("request")BaseQueryRequest request); void insert(@Param("apiSwaggerUrlDTO") ApiSwaggerUrlDTO apiSwaggerUrlDTO); @@ -23,4 +24,4 @@ public interface ExtScheduleMapper { int updateNameByResourceID(@Param("resourceId") String resourceId, @Param("name") String name); -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml index d234a83ebe..0322e6a5a0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtScheduleMapper.xml @@ -80,10 +80,21 @@ ) WHERE sch.`enable` = true AND sch.project_id = #{projectId,jdbcType=VARCHAR} - and sch.`group` in - - #{item} + + + + + + + and sch.group in + + #{value} + + + + +