package com.bootdo.system.config;

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;

/**
 * @author stw
 * @version 1.0.0 创建于 2018/1/18
 **/
@Configuration
public class AuthorizationInterceptorConf implements WebMvcConfigurer {

    @Autowired
    AuthorizationInterceptor authorizationInterceptor;
    /**
     * 不通过拦截器
     */
    private static final String[] EXCLUDE_RRI = {
            //不拦截公共资源
            "/webjars/**",
            "/error",

            //"/v2/api-docs",

            "/swagger-resources/configuration/security",
            "/swagger-resources/configuration/ui",
            "/swagger-resources",
            "/swagger-ui.html",
            "/static/**",
            //不拦截接口
            "/login",
            "/logout",
            "/sys/online/**"
    };

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authorizationInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(EXCLUDE_RRI);
    }


}
