package com.inkasso.auth.interceptor;

import org.springframework.util.CollectionUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Collections;
import java.util.List;

/**
 * @author 张超
 * @date 2021/11/3
 */
public class InterceptorInit implements WebMvcConfigurer {

  private List<HandlerInterceptor> handlerInterceptors;

  public InterceptorInit(List<HandlerInterceptor> args) {
    handlerInterceptors = args;
  }

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    if(!CollectionUtils.isEmpty(handlerInterceptors)){
      for(HandlerInterceptor hi:handlerInterceptors){
        registry.addInterceptor(hi);
      }
    }
  }
}
