package com.persagy.dmp.common.config;

import com.persagy.dmp.common.handler.AppContextHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description:
 * @author: lixing
 * @company: Persagy Technology Co.,Ltd
 * @since: 2021/3/8 10:06 上午
 * @version: V1.0
 **/
@Configuration
@Order(1)
public class CommonWebConfigurer implements WebMvcConfigurer {

    @Bean
    public AppContextHandler appContextHandler() {
        return new AppContextHandler();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] includePaths = {"/**"};
        String[] excludePaths = {"/**/*.html", "/**/*.js", "/**/*.css", "/swagger-resources"};
        // 设置拦截的路径、不拦截的路径、优先级等等
        registry.addInterceptor(appContextHandler()).order(10).addPathPatterns(includePaths).excludePathPatterns(excludePaths);
    }

}
