From f42b8c7a838eea11b0756ac91b4006a89e5d43d8 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 16 Jul 2020 17:09:15 +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 --- ruoyi-admin/pom.xml | 2 +- .../com/ruoyi/quartz/controller/SysJobController.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 7407a3f7d..257702d7b 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -55,7 +55,7 @@ springfox-swagger-ui - + mysql mysql-connector-java diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index 4bfe4f6d8..f9f0fab3c 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -21,6 +21,7 @@ import com.ruoyi.common.exception.job.TaskException; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.quartz.domain.SysJob; import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; /** * 调度任务信息操作处理 @@ -128,6 +129,10 @@ public class SysJobController extends BaseController @ResponseBody public AjaxResult addSave(@Validated SysJob job) throws SchedulerException, TaskException { + if (!CronUtils.isValid(job.getCronExpression())) + { + return AjaxResult.error("cron表达式不正确"); + } return toAjax(jobService.insertJob(job)); } @@ -150,6 +155,10 @@ public class SysJobController extends BaseController @ResponseBody public AjaxResult editSave(@Validated SysJob job) throws SchedulerException, TaskException { + if (!CronUtils.isValid(job.getCronExpression())) + { + return AjaxResult.error("cron表达式不正确"); + } return toAjax(jobService.updateJob(job)); }