package com.mosquito.project.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.mosquito.project.sdk.MosquitoClient;

@Configuration
@ConditionalOnClass(MosquitoClient.class)
@EnableConfigurationProperties({AppConfig.class, PosterConfig.class})
public class MosquitoAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public AppConfig appConfig() {
        return new AppConfig();
    }

    @Bean
    @ConditionalOnMissingBean
    public PosterConfig posterConfig() {
        return new PosterConfig();
    }

    @Bean
    @ConditionalOnMissingBean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    @ConditionalOnMissingBean
    public com.mosquito.project.service.ShareConfigService shareConfigService(AppConfig appConfig) {
        return new com.mosquito.project.service.ShareConfigService(appConfig);
    }

    @Bean
    @ConditionalOnMissingBean
    public com.mosquito.project.service.PosterRenderService posterRenderService(PosterConfig posterConfig, com.mosquito.project.service.ShortLinkService shortLinkService) {
        return new com.mosquito.project.service.PosterRenderService(posterConfig, shortLinkService);
    }
}
