CronUtil.java 728 Bytes
Newer Older
邓实川 committed
1 2 3 4 5 6
package cn.timer.api.utils.schedule;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import cn.timer.api.bean.sche.ScheduleTask;

7

邓实川 committed
8 9
public class CronUtil {

10 11 12
	// 默认cron 30秒一次
	private static String cron = "0 0 8 * * ?";
//	private static String cron = "0 50 14 * * ?";
邓实川 committed
13 14 15 16 17 18 19 20 21 22 23 24

	// 数据库cron
	public static String getCron(String className, String methodName) {
		ScheduleTask task = ScheduleTask.builder().build().selectOne(new LambdaQueryWrapper<ScheduleTask>()
				.eq(ScheduleTask::getClassName, className).eq(ScheduleTask::getMethodName, methodName)); // 数据库查询

		if (task != null && task.getCron() != null) {
			cron = task.getCron();
		}
		return cron;
	}
}