定时任务支持在线生成cron表达式
This commit is contained in:
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
@ -189,4 +190,31 @@ public class SysJobController extends BaseController
|
||||
{
|
||||
return jobService.checkCronExpressionIsValid(job.getCronExpression());
|
||||
}
|
||||
|
||||
/**
|
||||
* Cron表达式在线生成
|
||||
*/
|
||||
@GetMapping("/cron")
|
||||
public String cron()
|
||||
{
|
||||
return prefix + "/cron";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询cron表达式近5次的执行时间
|
||||
*/
|
||||
@GetMapping("/queryCronExpression")
|
||||
@ResponseBody
|
||||
public AjaxResult queryCronExpression(@RequestParam(value = "cronExpression", required = false) String cronExpression)
|
||||
{
|
||||
if (jobService.checkCronExpressionIsValid(cronExpression))
|
||||
{
|
||||
List<String> dateList = CronUtils.getRecentTriggerTime(cronExpression);
|
||||
return success(dateList);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error("表达式无效");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user