package com.huimv.apiservice.config;

import com.huimv.apiservice.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册验证token的拦截器
 * @author yinhao
 * @date 2021/4/19 20:41
 * @version V1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Bean
    public JWTInterceptor jwtInterceptor(){
        return new JWTInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor()).
                excludePathPatterns("/getToken").
                excludePathPatterns("/login").
                excludePathPatterns("/logout").
                excludePathPatterns("/captcha/send").
                excludePathPatterns("/swagger-resources/**").
                excludePathPatterns("/").
                excludePathPatterns("/*.ico").
                excludePathPatterns("/js/**").
                excludePathPatterns("/img/**").
                excludePathPatterns("/css/**").
                excludePathPatterns("/druid/**").
                excludePathPatterns("/doc.html").
                addPathPatterns("/**");
    }
}
