package com.ruansi.wflow;

import com.ruansi.common.security.annotation.EnableCustomConfig;
import com.ruansi.common.security.annotation.EnableRyFeignClients;
import com.ruansi.common.swagger.annotation.EnableCustomSwagger2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

import javax.annotation.PostConstruct;


/**
 * @author : willian fu
 * @date : 2022/6/27
 */
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
@MapperScan(basePackages = {"com.ruansi.wflow.mapper"})
public class AppStater {

    @Value("${datasource.dynamic.datasource.master.url}")
    private static String  exampleProperty;

    public static void main(String[] args) {
        SpringApplication.run(AppStater.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  流程模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "s数据源是:" + exampleProperty + "\n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }


    private Environment environment;

    public AppStater(Environment environment) {
        this.environment = environment;
    }


    @PostConstruct
    public void init() {
        // 判断是否读取到了 Nacos 配置文件
        String value = environment.getProperty("spring.datasource.dynamic.datasource.master.url");
        if (value != null) {
            System.out.println("成功读取到了 Nacos 配置文件！"+value);
        } else {
            System.out.println("未读取到 Nacos 配置文件！");
        }
    }

}
