正在显示
1 个修改的文件
包含
12 行增加
和
0 行删除
| @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody; | @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody; | ||
| 13 | import org.springframework.web.bind.annotation.RequestMapping; | 13 | import org.springframework.web.bind.annotation.RequestMapping; |
| 14 | import org.springframework.web.bind.annotation.RestController; | 14 | import org.springframework.web.bind.annotation.RestController; |
| 15 | import com.ruoyi.common.exception.job.TaskException; | 15 | import com.ruoyi.common.exception.job.TaskException; |
| 16 | +import com.ruoyi.common.utils.SecurityUtils; | ||
| 17 | +import com.ruoyi.common.utils.job.CronUtils; | ||
| 16 | import com.ruoyi.common.utils.poi.ExcelUtil; | 18 | import com.ruoyi.common.utils.poi.ExcelUtil; |
| 17 | import com.ruoyi.framework.aspectj.lang.annotation.Log; | 19 | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| 18 | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; | 20 | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| @@ -77,6 +79,11 @@ public class SysJobController extends BaseController | @@ -77,6 +79,11 @@ public class SysJobController extends BaseController | ||
| 77 | @PostMapping | 79 | @PostMapping |
| 78 | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException | 80 | public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| 79 | { | 81 | { |
| 82 | + if (!CronUtils.isValid(sysJob.getCronExpression())) | ||
| 83 | + { | ||
| 84 | + return AjaxResult.error("cron表达式不正确"); | ||
| 85 | + } | ||
| 86 | + sysJob.setCreateBy(SecurityUtils.getUsername()); | ||
| 80 | return toAjax(jobService.insertJob(sysJob)); | 87 | return toAjax(jobService.insertJob(sysJob)); |
| 81 | } | 88 | } |
| 82 | 89 | ||
| @@ -88,6 +95,11 @@ public class SysJobController extends BaseController | @@ -88,6 +95,11 @@ public class SysJobController extends BaseController | ||
| 88 | @PutMapping | 95 | @PutMapping |
| 89 | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException | 96 | public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException |
| 90 | { | 97 | { |
| 98 | + if (!CronUtils.isValid(sysJob.getCronExpression())) | ||
| 99 | + { | ||
| 100 | + return AjaxResult.error("cron表达式不正确"); | ||
| 101 | + } | ||
| 102 | + sysJob.setUpdateBy(SecurityUtils.getUsername()); | ||
| 91 | return toAjax(jobService.updateJob(sysJob)); | 103 | return toAjax(jobService.updateJob(sysJob)); |
| 92 | } | 104 | } |
| 93 | 105 |
-
请 注册 或 登录 后发表评论