From 4088463adf5a33a43b7fddf3f66d65c220acf93d Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Jul 2020 16:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1cron?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/monitor/controller/SysJobController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java b/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java index 9894cd8d2..742d281c0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java @@ -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)); }