package com.luozhihui.project.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 *
 * 注册自定义拦截器
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 registration 拦截器
        InterceptorRegistration registration = registry.addInterceptor(new UserLoginInterceptor());
        // 拦截所有的路径
        registration.addPathPatterns("/**");

        // 添加不拦截路径 /api/user/login 是登录的请求, /api/user/register 注册的请求
        registration.excludePathPatterns(
                //后台管理员登录
                "/api/admin_login",
                //用户登录
                "/api/login",
                //用户注册
                "/api/user_register",
//                //发送验证码
                "/api/sendCode"
        );
    }
}
