package com.chaozhanggui.admin.system.interceptor;

import com.chaozhanggui.admin.system.util.RedisUtil;
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;


@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Autowired
    RedisUtil redisUtil;
    /**
     * 配置拦截器
     * @param registry 相当于拦截器的注册中心
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//       下面这句代码相当于添加一个拦截器   添加的拦截器就是我们刚刚创建的
        registry.addInterceptor(new LoginInterceptor(redisUtil))
                .addPathPatterns()
//       如果有静态资源的时候可以在这个地方放行
                .excludePathPatterns("/","/user/doLogin","/agency/mytest","/agency/queryAgency","/promotion/testRequest","/agency/sendmessage");
    }
}
