package com.yfd.platform;

import com.yfd.platform.annotation.rest.AnonymousGetMapping;
import com.yfd.platform.datasource.DynamicDataSourceConfig;
import com.yfd.platform.utils.SpringContextHolder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;

//@SpringBootApplication
@RestController
@EnableTransactionManagement
@ServletComponentScan("com.yfd.platform.config")
@MapperScan(basePackages = "com.yfd.platform.modules.*.convert.impl,com.yfd.platform.modules.*.mapper,com.yfd.platform.*.mapper")
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
@Import({DynamicDataSourceConfig.class})
@EnableCaching
@EnableScheduling
@EnableAsync
public class PlatformApplication {

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

	@Bean
	public SpringContextHolder springContextHolder() {
		return new SpringContextHolder();
	}

	@Bean
	public WebClient.Builder webClientBuilder() {
		return WebClient.builder();
	}
	/**
	 * 访问首页提示
	 *
	 * @return /
	 */
	@AnonymousGetMapping("/")
	public String index() {
		return "Backend service started successfully";
	}
}
