package com.chaozhanggui.admin.system;

import com.chaozhanggui.common.system.CommonConfig;
import com.chaozhanggui.common.system.util.ExceptionUtil;
import com.chaozhanggui.common.system.util.SpringContextHolder;
import com.chaozhanggui.dao.system.DaoConfig;
import com.chaozhanggui.system.AliPayServiceConfig;
import com.chaozhanggui.system.config.AliPayConfig;
import com.dianguang.cloud.ossservice.OssServiceConfig;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;


/**
 *  @author admin
 * @description 账户
 * @date 2021-04-17 17:09
 */
@SpringBootApplication
@EnableScheduling
@EntityScan(basePackageClasses = {Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class})
@MapperScan(basePackageClasses ={Shell.class,DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class} )
@ComponentScan(basePackageClasses ={ Shell.class, DaoConfig.class, OssServiceConfig.class, CommonConfig.class, AliPayServiceConfig.class})
@Slf4j
@Transactional
public class Shell {


    public static void main(String[] args) {
        SpringApplication.run(Shell.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return (args) -> {
            log.info("=========================启动完成==========================");
            ctx.getBean(ExceptionUtil.class).initException();
        };
    }

    @Bean
    public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
        PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
        propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
        return propertySourcesPlaceholderConfigurer;
    }
}
