package com.storlead.thirdparty.biz.config;

import com.storlead.thirdparty.api.service.ThirdPartyUserSyncService;
import com.storlead.thirdparty.biz.service.DefaultThirdPartyService;
import com.storlead.thirdparty.spi.ThirdPartyDirectorySyncClient;
import com.storlead.thirdparty.spi.ThirdPartyMessageClient;
import com.storlead.thirdparty.spi.ThirdPartyUserSyncClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * 注册 {@link DefaultThirdPartyService}，避免仅依赖组件扫描时漏扫。
 */
@Configuration(proxyBeanMethods = false)
public class ThirdPartyBizAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(ThirdPartyUserSyncService.class)
    public DefaultThirdPartyService defaultThirdPartyService(
            List<ThirdPartyMessageClient> messageClientList,
            List<ThirdPartyDirectorySyncClient> syncClientList,
            List<ThirdPartyUserSyncClient> userSyncClientList) {
        return new DefaultThirdPartyService(messageClientList, syncClientList, userSyncClientList);
    }
}
