package com.smyhub.store.mengyastorebackendjava.config;

import com.smyhub.store.mengyastorebackendjava.security.AdminTokenInterceptor;
import com.smyhub.store.mengyastorebackendjava.security.BearerTokenInterceptor;
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 WebMvcConfig implements WebMvcConfigurer {

    private final AdminTokenInterceptor adminTokenInterceptor;
    private final BearerTokenInterceptor bearerTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminTokenInterceptor)
                .addPathPatterns("/api/admin/**")
                .excludePathPatterns("/api/admin/verify");

        registry.addInterceptor(bearerTokenInterceptor)
                .addPathPatterns(
                        "/api/orders",
                        "/api/wishlist",
                        "/api/wishlist/**",
                        "/api/chat/messages"
                );
    }
}
