package com.dsk.web.schedule;

import com.dsk.common.tenant.helper.TenantHelper;
import com.dsk.system.service.ISysTenantService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 租户相关定时任务类
 *
 * @author sxk
 * @date 2023.09.06
 */
@Component
@RequiredArgsConstructor
@Slf4j
public class TenantTimerTask {

    private final ISysTenantService tenantService;

    /**
     * 每6小时扫描并禁用已过期租户账号
     */
    @Scheduled(cron = "0 0 0/6 * * *")
    public void updateExpiredTenantStatus() {
        log.info("执行定时禁用已过期租户账号(6h/次)");
        TenantHelper.ignore(tenantService::handleExpiredTenant);
    }

}