package com.yonge.audio;

import java.util.ArrayList;
import java.util.List;

import com.yonge.cooleshow.common.constant.AppConstant;
import com.yonge.toolset.base.BaseApplication;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;

import com.spring4all.swagger.EnableSwagger2Doc;
import com.yonge.audio.config.LocalFastJsonHttpMessageConverter;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients("com.yonge.cooleshow")
@MapperScan(basePackages = {"com.yonge.cooleshow.biz.dal.dao", "com.yonge.cooleshow.biz.dal.mapper", "com.yonge.toolset.payment.core.dao"})
@ComponentScan(basePackages = {
        "com.yonge.netty", "com.yonge.cooleshow", "com.yonge.toolset"
})
@Configuration
@EnableSwagger2Doc
public class AudioAnalysisServerApplication {

    public static void main(String[] args) {
        BaseApplication.run(AppConstant.APPLICATION_AUDIO_ANALYSIS, AudioAnalysisServerApplication.class, args);
    }

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

    @Bean
    public HttpMessageConverters fastJsonHttpMessageConverters() {
        LocalFastJsonHttpMessageConverter converter = new LocalFastJsonHttpMessageConverter();
        List<MediaType> fastMediaTypes = new ArrayList<MediaType>();
        fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
        converter.setSupportedMediaTypes(fastMediaTypes);
        return new HttpMessageConverters(converter);
    }
}
