package com.fs.app.config;

import com.fs.app.interceptor.AuthorizationInterceptor;
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;

/**
 * MVC 配置
 * <p>
 * 公众号静默授权（/mp/silent/**）不做登录 Token 校验，显式排除以免后续扩大拦截范围时误伤。
 * </p>
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private AuthorizationInterceptor authorizationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor)
                .addPathPatterns("/app/**", "/store/app/**")
                .excludePathPatterns(
                        "/mp/silent/**",
                        "/",
                        "/index.html"
                );
    }
}
