Merge branch 'v1.1' of github.com:fit2cloudrd/metersphere-server into v1.1

This commit is contained in:
Captain.B 2020-07-23 10:26:46 +08:00
commit b5f2afc4f8
1 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ScheduleMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.job.sechedule.ApiTestJob;
import io.metersphere.job.sechedule.ScheduleManager;
import org.apache.commons.lang3.StringUtils;
import org.quartz.JobKey;
@ -52,12 +53,15 @@ public class ScheduleService {
}
public int deleteSchedule(String scheduleId) {
Schedule schedule = scheduleMapper.selectByPrimaryKey(scheduleId);
removeJob(schedule.getResourceId());
return scheduleMapper.deleteByPrimaryKey(scheduleId);
}
public int deleteByResourceId(String resourceId) {
ScheduleExample scheduleExample = new ScheduleExample();
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
removeJob(resourceId);
return scheduleMapper.deleteByExample(scheduleExample);
}
@ -99,6 +103,10 @@ public class ScheduleService {
return schedule;
}
public void removeJob(String resourceId) {
scheduleManager.removeJob(ApiTestJob.getJobKey(resourceId), ApiTestJob.getTriggerKey(resourceId));
}
public void addOrUpdateCronJob(Schedule request, JobKey jobKey, TriggerKey triggerKey, Class clazz) {
Boolean enable = request.getEnable();
String cronExpression = request.getValue();