package com.fdkankan.ucenter.config;

import com.fdkankan.ucenter.interceptor.AppInterceptor;
import com.fdkankan.ucenter.interceptor.UcenterInterceptor;
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.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebAppConfig implements WebMvcConfigurer {

	@Autowired
	UcenterInterceptor ucenterInterceptor;
	@Autowired
	AppInterceptor appInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {

		registry.addInterceptor(ucenterInterceptor).addPathPatterns("/**")
				.excludePathPatterns(
						//"/user/virtualOrder/**",
						"/**/sso/**",
						"/**/app/**",
						"/**/test/**",
						"/**/_inner/**",
						"/**/fusion/**",
						"/**/scene/**",
						"/**/intercomMessage/**",
						"/**/order/pay/**",
						"/**/article/**",
						"/**/goods/version/**",
						"/**/inner/**",
						"/**/_manage/**",
						"/**/agentAduit/**",
						"/**/laser/**",
						"/**/vaild/cameras/**",
						"/**/hot/shop/**",
						"/**/getIncrementType/**",
						"/**/system/**",
						"/**/contactUs/**"
				);
		registry.addInterceptor(ucenterInterceptor).addPathPatterns("/**/user/scene/**")
				.excludePathPatterns(
						"/fd/**/user/scene/**",
						"/**/getArPathByNum/**"
				);
		registry.addInterceptor(ucenterInterceptor).addPathPatterns("/**/device/**");

		registry.addInterceptor(appInterceptor).addPathPatterns("/app/**")
				.excludePathPatterns(
						"/app/scene/getAppAllSceneByPage",
						"/app/camera/uploadUserCameraInfo",
						"/app/camera/checkCameraSpace"
				);
		WebMvcConfigurer.super.addInterceptors(registry);
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		WebMvcConfigurer.super.addResourceHandlers(registry);
	}

}

