package com.sino.mci.config;

import com.sino.mci.admin.security.AuthInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

    private final AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/msg-platform/api/v1/**", "/api/v1/**")
                .excludePathPatterns(
                        "/msg-platform/api/v1/account/login", "/api/v1/account/login",
                        "/msg-platform/api/v1/account/tenant", "/api/v1/account/tenant",
                        "/msg-platform/api/v1/account/user", "/api/v1/account/user",
                        "/msg-platform/api/v1/health", "/api/v1/health",
                        "/msg-platform/api/v1/channel-account/heartbeat", "/api/v1/channel-account/heartbeat");
    }
}
