package com.persagy.adm.server.custom.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class AppContextConfig implements WebMvcConfigurer {

    @Autowired
    TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new AppContextInterceptor());
        registration.addPathPatterns("/adm/adm-file/**");

        InterceptorRegistration registration1 = registry.addInterceptor(new TraceIdInterceptor());
        registration1.addPathPatterns("/**");

        registry.addInterceptor(tokenInterceptor).order(Integer.MAX_VALUE).addPathPatterns("/adm/**").excludePathPatterns("/adm/getUserInfo");

    }
}
