package com.ematou.wxservice.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author lhm
 * @version 1.0
 * 2021-04-30 14:02
 */
@Configuration
@EnableAspectJAutoProxy
@MapperScan("com.ematou.wxservice.mapper")
@ComponentScan("com.ematou.wxservice.*")
public class AppConfig {

    @Bean
    public WeChatGeneralConfig wxGeneralConfig() {
        return new WeChatGeneralConfig();
    }

    @Bean
    public RestTemplate restTemplate() {
        // 可发送HTTPS请求的RestTemplate
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setReadTimeout(60000);
        factory.setConnectTimeout(15000);
        return new RestTemplate(factory);
    }

}
