Merge branch 'v1.1' of github.com:fit2cloudrd/metersphere-server into v1.1
This commit is contained in:
commit
b5f2afc4f8
|
@ -7,6 +7,7 @@ import io.metersphere.base.mapper.ScheduleMapper;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.commons.utils.SessionUtils;
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
|
import io.metersphere.job.sechedule.ApiTestJob;
|
||||||
import io.metersphere.job.sechedule.ScheduleManager;
|
import io.metersphere.job.sechedule.ScheduleManager;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.quartz.JobKey;
|
import org.quartz.JobKey;
|
||||||
|
@ -52,12 +53,15 @@ public class ScheduleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteSchedule(String scheduleId) {
|
public int deleteSchedule(String scheduleId) {
|
||||||
|
Schedule schedule = scheduleMapper.selectByPrimaryKey(scheduleId);
|
||||||
|
removeJob(schedule.getResourceId());
|
||||||
return scheduleMapper.deleteByPrimaryKey(scheduleId);
|
return scheduleMapper.deleteByPrimaryKey(scheduleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deleteByResourceId(String resourceId) {
|
public int deleteByResourceId(String resourceId) {
|
||||||
ScheduleExample scheduleExample = new ScheduleExample();
|
ScheduleExample scheduleExample = new ScheduleExample();
|
||||||
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
|
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
|
||||||
|
removeJob(resourceId);
|
||||||
return scheduleMapper.deleteByExample(scheduleExample);
|
return scheduleMapper.deleteByExample(scheduleExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +103,10 @@ public class ScheduleService {
|
||||||
return schedule;
|
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) {
|
public void addOrUpdateCronJob(Schedule request, JobKey jobKey, TriggerKey triggerKey, Class clazz) {
|
||||||
Boolean enable = request.getEnable();
|
Boolean enable = request.getEnable();
|
||||||
String cronExpression = request.getValue();
|
String cronExpression = request.getValue();
|
||||||
|
|
Loading…
Reference in New Issue