package egovframework.com.its.web.server.config;

import egovframework.com.its.web.server.interceptors.AdminInterceptor;
import egovframework.com.its.web.server.interceptors.LogAdapterInterceptor;
import egovframework.com.its.web.server.interceptors.LoginAdapterInterceptor;
import lombok.RequiredArgsConstructor;
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
@RequiredArgsConstructor
public class WebMvcConfigure implements WebMvcConfigurer {
    private final AdminInterceptor adminInterceptor;

    private final LogAdapterInterceptor logAdapterInterceptor;

    private final LoginAdapterInterceptor loginAdapterInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptor).addPathPatterns("/ptatms/index.do");
        registry.addInterceptor(logAdapterInterceptor).addPathPatterns("/main/main.do",
                "/intro/location.do", "/intro/service.do", "/intro/center.do",
                "/traffic/cctv.do", "/traffic/popupCctv.do", "/traffic/popupCctvM.do",
                "/traffic/vms.do", "/traffic/incd.do", "/traffic/realtime.do",
                "/statistics/info.do", "/statistics/ixrTrafficStats.do", "/statistics/connStat.do",
                "/archive/archiveList.do", "/notice/noticeList.do", "/relate/relateSite.do");
        registry.addInterceptor(loginAdapterInterceptor).addPathPatterns("/ptatms/**/*").excludePathPatterns("/ptatms/index.do", "/ptatms/login.do");
    }
}
