package com.example.common.config;

import jakarta.annotation.Resource;
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 WebConfig implements WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    // 加自定义拦截器JwtInterceptor，设置拦截规则
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/login", "/register", "/files/**", "/role/selectAll","/institution/selectAll")
                .excludePathPatterns("/doctor") // 放行医生列表获取接口，用于患者注册时选择医生
                .excludePathPatterns("/ws/**", "/notification/**") // 放行WebSocket和通知相关的路径
                .excludePathPatterns("/eventInstitution/checkAndUpdateEventStatus"); // 放行事件状态检查接口
    }
}