InterceptorCfg.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.zy.bms.config;
  2. import com.zy.bms.config.interceptor.OperateAuthInterceptor;
  3. import com.zy.bms.config.interceptor.UbiAppAuthInterceptor;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.context.annotation.Profile;
  6. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  7. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  8. import javax.annotation.Resource;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. /**
  12. * 配置拦截器
  13. *
  14. * @author chenyi
  15. * Create on 2019/10/10
  16. */
  17. @Profile("prod")
  18. @Configuration
  19. public class InterceptorCfg implements WebMvcConfigurer {
  20. @Resource
  21. private UbiAppAuthInterceptor ubiAppAuthInterceptor;
  22. @Resource
  23. private OperateAuthInterceptor operateAuthInterceptor;
  24. // 白名单
  25. private static List<String> whiteList = new ArrayList<>();
  26. static {
  27. whiteList.add("/bms/api/operate/admin/login.do");
  28. whiteList.add("/bms/api/operate/user/login.do");
  29. }
  30. /**
  31. * 添加自定义拦截器
  32. */
  33. @Override
  34. public void addInterceptors(InterceptorRegistry registry) {
  35. registry.addInterceptor(ubiAppAuthInterceptor)
  36. .addPathPatterns("/bms/api/ubiapp/**");
  37. registry.addInterceptor(operateAuthInterceptor)
  38. .addPathPatterns("/bms/api/operate/**")
  39. .excludePathPatterns(whiteList);
  40. }
  41. }