package com.usoftchina.bi.auth.config;

import com.usoftchina.bi.auth.interceptor.SecurityInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
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 ConfigAdapter implements WebMvcConfigurer {

    private static final Logger logger = LoggerFactory.getLogger(ConfigAdapter.class);

    @Bean
    SecurityInterceptor securityInterceptor() {
        return new SecurityInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(securityInterceptor())
                .addPathPatterns("/DataBase/*").excludePathPatterns("/DataBase/getColumnData")
        .addPathPatterns("/getUserList")
        .addPathPatterns("/*User*")
        .addPathPatterns("/*User*/*")
        .addPathPatterns("/home/defaultDashboard/*")
        .addPathPatterns("/Connector/*").excludePathPatterns("/Connector/getListDataConnector")
        .excludePathPatterns("/Connector/getConnectorGroup")
        .excludePathPatterns("/getDashboardByCode")
        .excludePathPatterns("/getSharedDashboard")
        .excludePathPatterns("/Connector/getConnectorData");
    }
}
