Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
4088463a
Commit
4088463a
authored
Jul 16, 2020
by
RuoYi
Browse files
定时任务cron表达式验证
parent
dd7a9850
Changes
1
Hide whitespace changes
Inline
Side-by-side
ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java
View file @
4088463a
...
...
@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ruoyi.common.exception.job.TaskException
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.job.CronUtils
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.framework.aspectj.lang.annotation.Log
;
import
com.ruoyi.framework.aspectj.lang.enums.BusinessType
;
...
...
@@ -77,6 +79,11 @@ public class SysJobController extends BaseController
@PostMapping
public
AjaxResult
add
(
@RequestBody
SysJob
sysJob
)
throws
SchedulerException
,
TaskException
{
if
(!
CronUtils
.
isValid
(
sysJob
.
getCronExpression
()))
{
return
AjaxResult
.
error
(
"cron表达式不正确"
);
}
sysJob
.
setCreateBy
(
SecurityUtils
.
getUsername
());
return
toAjax
(
jobService
.
insertJob
(
sysJob
));
}
...
...
@@ -88,6 +95,11 @@ public class SysJobController extends BaseController
@PutMapping
public
AjaxResult
edit
(
@RequestBody
SysJob
sysJob
)
throws
SchedulerException
,
TaskException
{
if
(!
CronUtils
.
isValid
(
sysJob
.
getCronExpression
()))
{
return
AjaxResult
.
error
(
"cron表达式不正确"
);
}
sysJob
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
return
toAjax
(
jobService
.
updateJob
(
sysJob
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment