package org.xyzh.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.xyzh.common.auth.config.SecurityConfig;
import org.xyzh.common.auth.config.WebMvcConfig;
import org.xyzh.common.auth.config.GatewayAuthConfig;

/**
 * @description Gateway 网关启动类
 * @author yslg
 * @since 2025-12-02
 */
@SpringBootApplication(exclude = {
    DataSourceAutoConfiguration.class  // Gateway 不需要数据源
})
@EnableDiscoveryClient
@ComponentScan(
    basePackages = {
        "org.xyzh.gateway",    // 当前 gateway 模块
        "org.xyzh.common"      // 公共模块（包括 common-auth）
    },
    excludeFilters = {
        // 排除 Spring MVC 相关配置，Gateway 使用 WebFlux
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
            SecurityConfig.class,      // Spring MVC Security配置
            WebMvcConfig.class,        // Spring MVC配置
            GatewayAuthConfig.class    // 微服务Gateway模式配置（使用Servlet Filter）
        })
    }
)
public class GatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
        System.out.println("========================================");
        System.out.println("    Gateway 网关服务启动成功！");
        System.out.println("========================================");
    }
}
