package com.ruoyi.xq.job;

import com.ruoyi.xq.service.SmsVerifyService;
import com.ruoyi.xq.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ClearDaysJob {

    @Autowired
    private SmsVerifyService smsVerifyService;
    @Autowired
    private JobManager jobManager;


    // 凌晨8点执行
    @Scheduled(cron = "0 0 1 * * ? ")
    public void clearRun() {
        try {
            log.info("定时删除短信记录== 开始");
            smsVerifyService.clearSmsVerify(60);
            log.info("定时删除短信记录== 结束");
        }catch (Exception e){
            log.error("定时删除短信记录== 异常",e);
        }

        try {
            log.info("定时更新用户年龄== 开始");
            jobManager.updateAge();
            log.info("定时更新用户年龄== 结束");
        }catch (Exception e){
            log.error("定时更新用户年龄== 异常",e);
        }

    }
}
