package com.hz.pm.api.user.task;

import com.hz.pm.api.user.manage.SyncMhUserOrgManage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;


/**
 * <p>
 * SyncMhCompanyTask
 * </p>
 *
 * @author WendyYang
 * @since 11:02 2023/12/25
 */
@Slf4j
@Component
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = SyncMhCompanyProperties.PREFIX, value = "open", matchIfMissing = true)
public class SyncMhCompanyTask {

    private final SyncMhUserOrgManage syncMhUserOrgManage;

    @Scheduled(fixedRateString = "#{syncMhCompanyProperties.getFixedRate()}", timeUnit = TimeUnit.HOURS)
    public void execute() {
        syncMhUserOrgManage.syncCompany();
    }

}
