package com.ruoyi.web.work.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //在此处，将拦截器注册为一个 Bean
    @Bean
    public TokenInterceptor tokenInterceptor() {
        return new TokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(tokenInterceptor());
        registration.addPathPatterns("/app/**");
        registration.excludePathPatterns("/app/user/login"); //排除
        registration.excludePathPatterns("/app/home/**"); //排除
        registration.excludePathPatterns("/app/notice/**"); //排除
        registration.excludePathPatterns("/app/knowledge/**"); //排除
        registration.excludePathPatterns("/app/doctor/**"); //排除
        registration.excludePathPatterns("/app/department/**"); //排除
        registration.excludePathPatterns("/app/common/type/*"); //排除
        registration.excludePathPatterns("/app/common/captcha"); //排除
        registration.excludePathPatterns("/app/common/introduction/*"); //排除


    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    }
}

