package com.kym.admin.jobs;

import com.kym.service.MpRelationService;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author skyline
 * 公众号用户关联
 * 2024-08-07
 */
@Component
@Slf4j
public class MpUserRelationJob {

    private final MpRelationService mpRelationService;

    public MpUserRelationJob(MpRelationService mpRelationService) {
        this.mpRelationService = mpRelationService;
    }

    // 每天凌晨1点执行一次
    @Scheduled(cron = "0 0 1 * * ?")
    public void executeMpUserRelationJob() throws WxErrorException {
        log.info("公众号用户关联处理启动...");
        mpRelationService.batchBindMpUser();
        log.info("公众号用户关联结束...");
    }

}
