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 30秒一次
	private static String cron = "0 0 8 * * ?";
//	private static String cron = "0 50 14 * * ?";

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