package com.sqx;

import com.sqx.modules.pay.wuyou.WuyouPay;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.Map;

/**
 * @author GYJ
 */
@EnableScheduling
@SpringBootApplication
public class SqxApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(SqxApplication.class, args);
		context.getEnvironment().getPropertySources().forEach(source -> {
			if (source.getName().contains("application-dev.yml") || source.getName().contains("application-prod.yml")) {
				if (source.getSource() instanceof Map) {
					((Map<String, Object>) source.getSource()).forEach((key, value) -> {
						System.out.println(key + ": " + value);
						if ("pay.orderNotifyUrl".equals(key)) {
							WuyouPay.setNotifyUrl(value.toString());
						}
						if ("pay.extractNotifyUrl".equals(key)) {
							WuyouPay.setExtractNotifyUrl(value.toString());
						}
					});
				}
			}
		});
		System.out.println("(♥◠‿◠)ﾉﾞ  短剧系统启动成功   ლ(´ڡ`ლ)ﾞ  \n"+
				"       _    \n" +
				"      | |   \n" +
				"  ___ | | __\n" +
				" / _ \\| |/ /\n" +
				"| (_) |   < \n" +
				" \\___/|_|\\_\\");

	}

}
