package com.ema.admin;

import com.burukeyou.retry.spring.EnableFastRetry;
import com.burukeyou.uniapi.annotation.UniAPIScan;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.dromara.x.file.storage.spring.EnableFileStorage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;


@Slf4j
@SpringBootApplication
@EnableScheduling
@EnableTransactionManagement // 开启事务支持
@EnableAspectJAutoProxy // 开启AOP代理
@EnableFastRetry // 开启重试机制
@EnableCaching  // 开启缓存支持
@EnableFileStorage // 开启文件存储
@ComponentScan(basePackages = {"com.ema"})
@UniAPIScan("com.ema.admin.remote")
public class AdminAppStarter {

    @SneakyThrows
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(AdminAppStarter.class, args);
        Environment env = context.getEnvironment();
        StringBuffer sb = new StringBuffer().append("\n");
        sb.append("##################	Started AdminAppStarter ##################").append("\n");
        sb.append("Application Name: ").append(env.getProperty("spring.application.name")).append("\n");
        sb.append("Application Local: ").append("http://").append(InetAddress.getLocalHost().getHostAddress()).append(":").append(env.getProperty("server.port")).append("\n");
        sb.append("Application Swagger: ").append("http://").append(InetAddress.getLocalHost().getHostAddress()).append(":").append(env.getProperty("server.port")).append("/doc.html").append("\n");
        sb.append("##################	       Started  SUCCESS       ##################").append("\n");
        log.info(sb.toString());
    }
}
