package com.chushang.system;

import com.chushang.common.core.enums.AppStartType;
import com.chushang.common.feign.annotation.EnableOnnFeignClients;
import com.chushang.common.feign.annotation.EnableTransferFeign;
import com.chushang.security.annotation.EnableCustomConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author by zhaowenyuan create 2022/8/18 17:08
 */
@EnableDiscoveryClient
@EnableOnnFeignClients
@EnableTransactionManagement
@SpringBootApplication(scanBasePackages = {"com.chushang.**"})
@EnableCustomConfig
//启用服务调用的参数传递，包含链路追踪日志
@EnableTransferFeign
@ServletComponentScan
public class SystemApplication extends SpringBootServletInitializer {
    private final static Logger log = LoggerFactory.getLogger(SystemApplication.class);
    private final static String APP_NAME = "系统管理服务应用";

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        log.info(AppStartType.START_FORMAT, AppStartType.web_server.type(), APP_NAME);
        SpringApplicationBuilder run = application.sources(SystemApplication.class);
        log.info(AppStartType.END_FORMAT, AppStartType.web_server.type(), APP_NAME);
        return run;
    }

    public static void main(String[] args) throws Exception {
        log.info(AppStartType.START_FORMAT, AppStartType.main.type(), APP_NAME);
        SpringApplication.run(SystemApplication.class, args);

        log.info(AppStartType.END_FORMAT, AppStartType.main.type(), APP_NAME);
    }
}
