InterceptorCfg.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /**
  21. * 身份验证拦截器
  22. */
  23. @Resource
  24. private UbiAppAuthInterceptor ubiAppAuthInterceptor;
  25. @Resource
  26. private OperateAuthInterceptor operateAuthInterceptor;
  27. // 白名单
  28. private static List<String> whiteList = new ArrayList<>();
  29. static {
  30. whiteList.add("/bms/api/operate/admin/login.do");
  31. whiteList.add("/bms/api/common/author.do");
  32. }
  33. /**
  34. * 添加自定义拦截器
  35. */
  36. @Override
  37. public void addInterceptors(InterceptorRegistry registry) {
  38. registry.addInterceptor(ubiAppAuthInterceptor)
  39. .addPathPatterns("/bms/api/ubiapp/**")
  40. .excludePathPatterns(whiteList);
  41. registry.addInterceptor(operateAuthInterceptor)
  42. .addPathPatterns("/bms/api/operate/**")
  43. .excludePathPatterns(whiteList);
  44. }
  45. }