From d3040ee9df97eafb46b8aac85afd35f717ec0c3c Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 9 Dec 2020 09:56:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=8E=BB=E9=99=A4=E9=87=8D=E5=90=88=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiAutomationController.java | 12 ------ .../api/service/ApiAutomationService.java | 31 ++------------ .../commons/constants/ScheduleGroup.java | 2 +- .../job/sechedule/ScenarioJob.java | 42 ------------------- .../automation/scenario/ApiScenarioList.vue | 27 +++--------- .../scenario/ScenarioExtendBtns.vue | 36 ++++++++-------- 6 files changed, 28 insertions(+), 122 deletions(-) delete mode 100644 backend/src/main/java/io/metersphere/job/sechedule/ScenarioJob.java diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 78b9d27964..6d46f0e708 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -9,7 +9,6 @@ import io.metersphere.api.dto.automation.SaveApiScenarioRequest; import io.metersphere.api.dto.definition.RunDefinitionRequest; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.base.domain.ApiScenario; -import io.metersphere.base.domain.Schedule; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; @@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; - import java.util.List; @RestController @@ -48,16 +46,6 @@ public class ApiAutomationController { apiAutomationService.update(request, bodyFiles); } - @PostMapping(value = "/schedule/update") - public void updateSchedule(@RequestBody Schedule schedule) { - apiAutomationService.updateSchedule(schedule); - } - - @PostMapping(value = "/schedule/create") - public void createSchedule(@RequestBody Schedule schedule) { - apiAutomationService.createSchedule(schedule); - } - @GetMapping("/delete/{id}") public void delete(@PathVariable String id) { apiAutomationService.delete(id); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index e8bb28bd11..d52b7cdebd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -17,14 +17,13 @@ import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiTagMapper; import io.metersphere.base.mapper.ext.ExtApiScenarioMapper; -import io.metersphere.commons.constants.*; +import io.metersphere.commons.constants.APITestStatus; +import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.i18n.Translator; -import io.metersphere.job.sechedule.ApiTestJob; -import io.metersphere.job.sechedule.ScenarioJob; -import io.metersphere.service.ScheduleService; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.jorphan.collections.HashTree; @@ -35,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; - import java.io.*; import java.util.ArrayList; import java.util.LinkedList; @@ -58,8 +56,6 @@ public class ApiAutomationService { private ApiTestEnvironmentService environmentService; @Resource private ApiScenarioReportService apiReportService; - @Resource - private ScheduleService scheduleService; private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @@ -125,27 +121,6 @@ public class ApiAutomationService { createBodyFiles(bodyUploadIds, bodyFiles); } - private Schedule buildApiTestSchedule(Schedule request) { - Schedule schedule = scheduleService.buildApiTestSchedule(request); - schedule.setJob(ScenarioJob.class.getName()); - schedule.setGroup(ScheduleGroup.SCENARIO_TEST.name()); - schedule.setType(ScheduleType.CRON.name()); - return schedule; - } - - private void addOrUpdateApiTestCronJob(Schedule request) { - scheduleService.addOrUpdateCronJob(request, ApiTestJob.getJobKey(request.getResourceId()), ApiTestJob.getTriggerKey(request.getResourceId()), ApiTestJob.class); - } - - public void updateSchedule(Schedule schedule) { - scheduleService.addSchedule(buildApiTestSchedule(schedule)); - addOrUpdateApiTestCronJob(schedule); - } - public void createSchedule(Schedule request) { - scheduleService.addSchedule(buildApiTestSchedule(request)); - addOrUpdateApiTestCronJob(request); - } - public void update(SaveApiScenarioRequest request, List bodyFiles) { checkNameExist(request); List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); diff --git a/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java b/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java index 8094a7098f..09bbf02589 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ScheduleGroup.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum ScheduleGroup { - API_TEST, PERFORMANCE_TEST,SCENARIO_TEST + API_TEST, PERFORMANCE_TEST } diff --git a/backend/src/main/java/io/metersphere/job/sechedule/ScenarioJob.java b/backend/src/main/java/io/metersphere/job/sechedule/ScenarioJob.java deleted file mode 100644 index 989a5984f0..0000000000 --- a/backend/src/main/java/io/metersphere/job/sechedule/ScenarioJob.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.metersphere.job.sechedule; - -import io.metersphere.api.dto.automation.RunScenarioRequest; -import io.metersphere.api.service.ApiAutomationService; -import io.metersphere.commons.constants.ReportTriggerMode; -import io.metersphere.commons.constants.ScheduleGroup; -import io.metersphere.commons.utils.CommonBeanFactory; -import org.quartz.JobExecutionContext; -import org.quartz.JobKey; -import org.quartz.TriggerKey; - -import java.util.ArrayList; -import java.util.List; - - -public class ScenarioJob extends MsScheduleJob { - - ApiAutomationService apiAutomationService; - - public ScenarioJob() { - apiAutomationService = (ApiAutomationService) CommonBeanFactory.getBean(ApiAutomationService.class); - } - - @Override - void businessExecute(JobExecutionContext context) { - RunScenarioRequest request = new RunScenarioRequest(); - request.setId(resourceId); - List ids = new ArrayList<>(); - ids.add(resourceId); - request.setScenarioIds(ids); - request.setTriggerMode(ReportTriggerMode.SCHEDULE.name()); - apiAutomationService.run(request); - } - - public static JobKey getJobKey(String testId) { - return new JobKey(testId, ScheduleGroup.SCENARIO_TEST.name()); - } - - public static TriggerKey getTriggerKey(String testId) { - return new TriggerKey(testId, ScheduleGroup.SCENARIO_TEST.name()); - } -} diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 65cf6dbb0d..faccabd1b5 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -45,12 +45,13 @@ - + @@ -63,13 +64,6 @@ - - - - - - @@ -84,12 +78,12 @@ import {getUUID} from "@/common/js/utils"; import MsApiReportDetail from "../report/ApiReportDetail"; import MsTableMoreBtn from "./TableMoreBtn"; - import MsScheduleConfig from "../../../common/components/MsScheduleConfig"; - import MsScheduleEdit from "../../../common/components/MsScheduleEdit"; + import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns"; + export default { name: "MsApiScenarioList", - components: {ShowMoreBtn, MsTablePagination, MsTableHeader, MsTag, MsApiReportDetail, MsTableMoreBtn, MsScheduleConfig, MsScheduleEdit}, + components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons}, props: { currentProject: Object, currentModule: Object, @@ -117,15 +111,6 @@ name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute } ], - tableButtons: [ - { - name: this.$t('api_test.automation.remove'), handleClick: this.remove - }, { - name: '查看引用', handleClick: this.handleQuote - }, { - name: this.$t('commons.trigger_mode.schedule'), handleClick: this.handleSchedule - } - ], } }, watch: { diff --git a/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue b/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue index fa42193b8b..27fd0f24ea 100644 --- a/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue +++ b/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue @@ -11,28 +11,28 @@