package com.sino.mci.channel.scheduler;

import com.sino.mci.channel.service.ChannelAccountService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class ChannelAccountHealthScheduler {

    private static final int OFFLINE_TIMEOUT_SECONDS = 120;

    private final ChannelAccountService accountService;

    @Scheduled(fixedDelayString = "${channel.account.health.interval:60000}")
    public void checkOfflineAccounts() {
        int count = accountService.checkOfflineAccounts(OFFLINE_TIMEOUT_SECONDS);
        if (count > 0) {
            log.info("账号健康检查完成，共标记 {} 个账号为离线", count);
        }
    }
}
