package com.malk.pro.config;

import com.malk.pro.tenant.TenantInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * mjava-pro 的 MVC 拦截器注册
 *
 * <p>与基座 WebConfiguration 共存：Spring 会同时调用所有 WebMvcConfigurer。
 * 本配置仅追加 TenantInterceptor，不影响基座的 RequestInterceptor / AuthInterceptor。</p>
 */
@Configuration
public class ProWebConfig implements WebMvcConfigurer {

    @Autowired
    private TenantInterceptor tenantInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tenantInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/actuator/**",
                        "/_admin/**",
                        "/assets/**",
                        "/templates/**",
                        "/static/**",
                        "/web2/**"
                );
    }
}
