mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-08 21:37:42 +00:00
定时任务cron表达式验证
This commit is contained in:
@@ -197,10 +197,16 @@ public class LogAspect
|
|||||||
for (int i = 0; i < paramsArray.length; i++)
|
for (int i = 0; i < paramsArray.length; i++)
|
||||||
{
|
{
|
||||||
if (!isFilterObject(paramsArray[i]))
|
if (!isFilterObject(paramsArray[i]))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Object jsonObj = JSON.toJSON(paramsArray[i]);
|
Object jsonObj = JSON.toJSON(paramsArray[i]);
|
||||||
params += jsonObj.toString() + " ";
|
params += jsonObj.toString() + " ";
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return params.trim();
|
return params.trim();
|
||||||
|
@@ -21,8 +21,10 @@ import com.ruoyi.common.core.web.domain.AjaxResult;
|
|||||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
import com.ruoyi.common.log.annotation.Log;
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||||
import com.ruoyi.job.domain.SysJob;
|
import com.ruoyi.job.domain.SysJob;
|
||||||
import com.ruoyi.job.service.ISysJobService;
|
import com.ruoyi.job.service.ISysJobService;
|
||||||
|
import com.ruoyi.job.util.CronUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度任务信息操作处理
|
* 调度任务信息操作处理
|
||||||
@@ -79,6 +81,11 @@ public class SysJobController extends BaseController
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
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));
|
return toAjax(jobService.insertJob(sysJob));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +97,11 @@ public class SysJobController extends BaseController
|
|||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
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));
|
return toAjax(jobService.updateJob(sysJob));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user