|
|
@ -79,18 +79,22 @@ public class SysJobController extends BaseController |
|
|
|
@PreAuthorize("@ss.hasPermi('monitor:job:add')") |
|
|
|
@PreAuthorize("@ss.hasPermi('monitor:job:add')") |
|
|
|
@Log(title = "定时任务", businessType = BusinessType.INSERT) |
|
|
|
@Log(title = "定时任务", businessType = BusinessType.INSERT) |
|
|
|
@PostMapping |
|
|
|
@PostMapping |
|
|
|
public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
|
|
|
public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!CronUtils.isValid(sysJob.getCronExpression())) |
|
|
|
if (!CronUtils.isValid(job.getCronExpression())) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return AjaxResult.error("新增任务'" + sysJob.getJobName() + "'失败,Cron表达式不正确"); |
|
|
|
return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) |
|
|
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return AjaxResult.error("新增任务'" + sysJob.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); |
|
|
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); |
|
|
|
} |
|
|
|
} |
|
|
|
sysJob.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
|
|
|
return toAjax(jobService.insertJob(sysJob)); |
|
|
|
{ |
|
|
|
|
|
|
|
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
job.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
|
|
|
|
return toAjax(jobService.insertJob(job)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -99,18 +103,22 @@ public class SysJobController extends BaseController |
|
|
|
@PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
|
|
|
@PreAuthorize("@ss.hasPermi('monitor:job:edit')") |
|
|
|
@Log(title = "定时任务", businessType = BusinessType.UPDATE) |
|
|
|
@Log(title = "定时任务", businessType = BusinessType.UPDATE) |
|
|
|
@PutMapping |
|
|
|
@PutMapping |
|
|
|
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
|
|
|
public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!CronUtils.isValid(sysJob.getCronExpression())) |
|
|
|
if (!CronUtils.isValid(job.getCronExpression())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return AjaxResult.error("修改任务'" + sysJob.getJobName() + "'失败,Cron表达式不正确"); |
|
|
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI)) |
|
|
|
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS })) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return AjaxResult.error("修改任务'" + sysJob.getJobName() + "'失败,目标字符串不允许'rmi://'调用"); |
|
|
|
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用"); |
|
|
|
} |
|
|
|
} |
|
|
|
sysJob.setUpdateBy(SecurityUtils.getUsername()); |
|
|
|
job.setUpdateBy(SecurityUtils.getUsername()); |
|
|
|
return toAjax(jobService.updateJob(sysJob)); |
|
|
|
return toAjax(jobService.updateJob(job)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|