package com.zfire.mall.manager.config;

import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@Configuration
public class MyWebAutoConfiguration implements WebMvcConfigurer {

    @Bean
    public CustomInterceptor initBuyServiceInterceptor() {
        return new CustomInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        WebMvcConfigurer.super.addInterceptors(registry);
        registry.addInterceptor(initBuyServiceInterceptor())
                .excludePathPatterns("/doc.html", "/webjars/**", "/swagger-resources/**", "/admin/user/**", "/common/**", "/wechat/**", "/buy/service/**")
                .addPathPatterns("/**")
        ;
    }
}
