package com.guwan.config;

import com.guwan.Interceptor.TokenInterceptor;
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;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加自定义的 Token 拦截器
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/user/**") // 拦截 /User/** 路径
                .excludePathPatterns("/user/login"); // 不拦截 /User/login 路径
    }
}
