package com.xjrsoft.module.job;

import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author dzx
 * @date 2024年8月8日
 */
@Component
@Slf4j
public class ActivityInfoTask {

    @Scheduled(cron = "0 */5 * * * ?")
    public void RefreshConnectionPool() {
//        String active = SpringUtil.getActiveProfile();
//        if(!"prod".equals(active)){
//            log.info("非正式环境，无法执行数据推送");
//            return;
//        }
        doExecute();
    }

    void doExecute(){
        String sql = "UPDATE activity_info SET STATUS = 2 WHERE delete_mark = 0 AND enroll_end_time < NOW()";
        SqlRunnerAdapter.db().update(sql);
        sql = "UPDATE activity_info SET STATUS = 3 WHERE delete_mark = 0 AND end_date < NOW()";
        SqlRunnerAdapter.db().update(sql);
    }


}
