package com.writeoff.module.system.job;

import com.writeoff.module.system.service.UserDelegationService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class UserDelegationExpireScheduler {
    private final UserDelegationService userDelegationService;

    public UserDelegationExpireScheduler(UserDelegationService userDelegationService) {
        this.userDelegationService = userDelegationService;
    }

    @Scheduled(fixedDelayString = "${app.user-delegation.expire-check-ms:60000}")
    public void expireDelegations() {
        userDelegationService.markAutoExpiredAllTenants();
    }
}
