|
@@ -79,18 +79,22 @@ public class SysJobController extends BaseController |
|
@@ -79,18 +79,22 @@ public class SysJobController extends BaseController |
|
79
|
@PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
79
|
@PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
|
80
|
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
80
|
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
|
81
|
@PostMapping
|
81
|
@PostMapping
|
|
82
|
- public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
82
|
+ public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException
|
|
83
|
{
|
83
|
{
|
|
84
|
- if (!CronUtils.isValid(sysJob.getCronExpression()))
|
84
|
+ if (!CronUtils.isValid(job.getCronExpression()))
|
|
85
|
{
|
85
|
{
|
|
86
|
- return AjaxResult.error("新增任务'" + sysJob.getJobName() + "'失败,Cron表达式不正确");
|
86
|
+ return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
|
87
|
}
|
87
|
}
|
|
88
|
- else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI))
|
88
|
+ else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
|
89
|
{
|
89
|
{
|
|
90
|
- return AjaxResult.error("新增任务'" + sysJob.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
90
|
+ return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
|
91
|
}
|
91
|
}
|
|
92
|
- sysJob.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
93
|
- return toAjax(jobService.insertJob(sysJob));
|
92
|
+ else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
|
|
|
93
|
+ {
|
|
|
|
94
|
+ return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
|
|
|
95
|
+ }
|
|
|
|
96
|
+ job.setCreateBy(SecurityUtils.getUsername());
|
|
|
|
97
|
+ return toAjax(jobService.insertJob(job));
|
|
94
|
}
|
98
|
}
|
|
95
|
|
99
|
|
|
96
|
/**
|
100
|
/**
|
|
@@ -99,18 +103,22 @@ public class SysJobController extends BaseController |
|
@@ -99,18 +103,22 @@ public class SysJobController extends BaseController |
|
99
|
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
103
|
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
|
100
|
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
104
|
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
|
101
|
@PutMapping
|
105
|
@PutMapping
|
|
102
|
- public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
106
|
+ public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException
|
|
103
|
{
|
107
|
{
|
|
104
|
- if (!CronUtils.isValid(sysJob.getCronExpression()))
|
108
|
+ if (!CronUtils.isValid(job.getCronExpression()))
|
|
|
|
109
|
+ {
|
|
|
|
110
|
+ return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
|
105
|
{
|
113
|
{
|
|
106
|
- return AjaxResult.error("修改任务'" + sysJob.getJobName() + "'失败,Cron表达式不正确");
|
114
|
+ return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
|
107
|
}
|
115
|
}
|
|
108
|
- else if (StringUtils.containsIgnoreCase(sysJob.getInvokeTarget(), Constants.LOOKUP_RMI))
|
116
|
+ else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
|
109
|
{
|
117
|
{
|
|
110
|
- return AjaxResult.error("修改任务'" + sysJob.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
118
|
+ return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
|
111
|
}
|
119
|
}
|
|
112
|
- sysJob.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
113
|
- return toAjax(jobService.updateJob(sysJob));
|
120
|
+ job.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
121
|
+ return toAjax(jobService.updateJob(job));
|
|
114
|
}
|
122
|
}
|
|
115
|
|
123
|
|
|
116
|
/**
|
124
|
/**
|