package com.zy.bms.config; import com.zy.bms.config.interceptor.OperateAuthInterceptor; import com.zy.bms.config.interceptor.UbiAppAuthInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; /** * 配置拦截器 * * @author chenyi * Create on 2019/10/10 */ @Profile("prod") @Configuration public class InterceptorCfg implements WebMvcConfigurer { @Resource private UbiAppAuthInterceptor ubiAppAuthInterceptor; @Resource private OperateAuthInterceptor operateAuthInterceptor; // 白名单 private static List whiteList = new ArrayList<>(); static { whiteList.add("/bms/api/operate/admin/login.do"); whiteList.add("/bms/api/operate/user/login.do"); } /** * 添加自定义拦截器 */ @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(ubiAppAuthInterceptor) .addPathPatterns("/bms/api/ubiapp/**"); registry.addInterceptor(operateAuthInterceptor) .addPathPatterns("/bms/api/operate/**") .excludePathPatterns(whiteList); } }