package com.usky.rule;

import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 数据规则引擎服务（对标 leo-rule-engine + MQTT 上报链路，RocketMQ 订阅触发）
 */
@EnableCustomSwagger2
@EnableFeignClients(basePackages = "com.usky")
@EnableScheduling
@MapperScan("com.usky.rule.mapper")
@ComponentScan("com.usky")
@SpringBootApplication
public class RuoYiSystemApplication {

    private static final Logger LOGGER = LoggerFactory.getLogger(RuoYiSystemApplication.class);

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(RuoYiSystemApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        LOGGER.info("\n----------------------------------------------------------\n\t" +
                "Application is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + (path == null ? "" : path) + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + (path == null ? "" : path) + "/\n\t" +
                "Api: \t\thttp://" + ip + ":" + port + (path == null ? "" : path) + "/swagger-ui/index.html\n\t" +
                "----------------------------------------------------------");
    }
}
