package cn.timer.api.utils.schedule;

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

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

public class CronUtil {

	// 默认cron 10秒一次
	private static String cron = "0/10 * * * * ?";

	// 数据库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;
	}
}