feat(测试跟踪): 测试计划定时任务快捷开关记录操作日志

--story=1008184 --user=陈建星 测试计划优化 https://www.tapd.cn/55049933/s/1202551
This commit is contained in:
chenjianxing 2022-07-15 15:59:28 +08:00 committed by jianxing
parent f783b00d37
commit 0813e6f659
5 changed files with 31 additions and 21 deletions

View File

@ -1074,13 +1074,10 @@ public class ApiAutomationService {
} }
public void updateSchedule(Schedule request) { public void updateSchedule(Schedule request) {
JobKey jobKey = null;
TriggerKey triggerKey = null;
Class clazz = null;
scheduleService.editSchedule(request); scheduleService.editSchedule(request);
jobKey = ApiScenarioTestJob.getJobKey(request.getResourceId()); JobKey jobKey = ApiScenarioTestJob.getJobKey(request.getResourceId());
triggerKey = ApiScenarioTestJob.getTriggerKey(request.getResourceId()); TriggerKey triggerKey = ApiScenarioTestJob.getTriggerKey(request.getResourceId());
clazz = ApiScenarioTestJob.class; Class clazz = ApiScenarioTestJob.class;
request.setJob(ApiScenarioTestJob.class.getName()); request.setJob(ApiScenarioTestJob.class.getName());
this.addOrUpdateApiScenarioCronJob(request); this.addOrUpdateApiScenarioCronJob(request);
scheduleService.resetJob(request, jobKey, triggerKey, clazz); scheduleService.resetJob(request, jobKey, triggerKey, clazz);

View File

@ -2,14 +2,10 @@ package io.metersphere.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.service.ApiAutomationService;
import io.metersphere.base.domain.Schedule; import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.controller.request.ScheduleRequest; import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.dto.ScheduleDao; import io.metersphere.dto.ScheduleDao;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.ScheduleService; import io.metersphere.service.ScheduleService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -21,8 +17,6 @@ import java.util.List;
public class ScheduleController { public class ScheduleController {
@Resource @Resource
private ScheduleService scheduleService; private ScheduleService scheduleService;
@Resource
private ApiAutomationService apiAutomationService;
@PostMapping("/list/{goPage}/{pageSize}") @PostMapping("/list/{goPage}/{pageSize}")
public List<ScheduleDao> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryScheduleRequest request) { public List<ScheduleDao> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryScheduleRequest request) {
@ -37,13 +31,11 @@ public class ScheduleController {
} }
@PostMapping(value = "/update") @PostMapping(value = "/update")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.UPDATE, title = "#request.name", beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = ScheduleService.class)
public void updateSchedule(@RequestBody Schedule request) { public void updateSchedule(@RequestBody Schedule request) {
scheduleService.updateSchedule(request); scheduleService.updateSchedule(request);
} }
@PostMapping(value = "/create") @PostMapping(value = "/create")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.CREATE, title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ScheduleService.class)
public void createSchedule(@RequestBody ScheduleRequest request) { public void createSchedule(@RequestBody ScheduleRequest request) {
scheduleService.createSchedule(request); scheduleService.createSchedule(request);
} }

View File

@ -10,6 +10,7 @@ import io.metersphere.base.domain.*;
import io.metersphere.commons.constants.*; import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.service.CheckPermissionService; import io.metersphere.service.CheckPermissionService;
@ -296,7 +297,22 @@ public class TestPlanController {
@PostMapping(value = "/update/scheduleByEnable") @PostMapping(value = "/update/scheduleByEnable")
public ScheduleDTO updateTestPlanBySchedule(@RequestBody ScheduleInfoRequest request) { public ScheduleDTO updateTestPlanBySchedule(@RequestBody ScheduleInfoRequest request) {
return testPlanService.updateTestPlanBySchedule(request); Schedule schedule = scheduleService.getSchedule(request.getTaskID());
schedule.setEnable(request.isEnable());
testPlanService.updateSchedule(schedule);
return testPlanService.getNextTriggerSchedule(schedule);
}
@PostMapping(value = "/schedule/update")
public void updateSchedule(@RequestBody Schedule request) {
testPlanService.updateSchedule(request);
}
@PostMapping(value = "/schedule/create")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.CREATE,
title = "#request.name", content = "#msClass.getLogDetails(#request)", msClass = ScheduleService.class)
public void createSchedule(@RequestBody ScheduleRequest request) {
scheduleService.createSchedule(request);
} }
} }

View File

@ -26,6 +26,7 @@ import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants; import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.log.utils.ReflexObjectUtil; import io.metersphere.log.utils.ReflexObjectUtil;
import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
@ -2085,11 +2086,15 @@ public class TestPlanService {
return time1 == null ? 0 : time1.getTime(); return time1 == null ? 0 : time1.getTime();
} }
public ScheduleDTO updateTestPlanBySchedule(ScheduleInfoRequest request) { @MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN_SCHEDULE, type = OperLogConstants.UPDATE, title = "#request.name",
beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = ScheduleService.class)
public Schedule updateSchedule(Schedule request) {
apiAutomationService.updateSchedule(request);
return request;
}
public ScheduleDTO getNextTriggerSchedule(Schedule schedule) {
ScheduleDTO scheduleDTO = new ScheduleDTO(); ScheduleDTO scheduleDTO = new ScheduleDTO();
Schedule schedule = scheduleService.getSchedule(request.getTaskID());
schedule.setEnable(request.isEnable());
apiAutomationService.updateSchedule(schedule);
BeanUtils.copyBean(scheduleDTO, schedule); BeanUtils.copyBean(scheduleDTO, schedule);
if (schedule.getEnable() != null && schedule.getEnable()) { if (schedule.getEnable() != null && schedule.getEnable()) {
scheduleDTO.setScheduleExecuteTime(getNextTriggerTime(schedule.getValue())); scheduleDTO.setScheduleExecuteTime(getNextTriggerTime(schedule.getValue()));

View File

@ -425,9 +425,9 @@ export default {
if (this.scheduleTaskType === "TEST_PLAN_TEST") { if (this.scheduleTaskType === "TEST_PLAN_TEST") {
param.scheduleFrom = "testPlan"; param.scheduleFrom = "testPlan";
// //
url = '/schedule/create'; url = '/test/plan/schedule/create';
if (param.id) { if (param.id) {
url = '/schedule/update'; url = '/test/plan/schedule/update';
} }
} else { } else {
param.scheduleFrom = "scenario"; param.scheduleFrom = "scenario";