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