MVCConfig.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package io.github.qifan777.knowledge.config;
  2. import io.github.qifan777.knowledge.interceptor.LoginInterceptor;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.data.redis.core.HashOperations;
  6. import org.springframework.data.redis.core.RedisTemplate;
  7. import org.springframework.data.redis.core.ValueOperations;
  8. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  9. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  10. /**
  11. * <p>
  12. *
  13. * </p>
  14. *
  15. * @author taohongrun
  16. * @since 2024/12/4
  17. */
  18. @Configuration
  19. public class MVCConfig implements WebMvcConfigurer {
  20. @Autowired
  21. RedisTemplate<String,String> redisTemplate;
  22. @Override
  23. public void addInterceptors(InterceptorRegistry registry) {
  24. ValueOperations<String,String> valueOperations = redisTemplate.opsForValue();
  25. registry.addInterceptor(new LoginInterceptor(valueOperations))
  26. .addPathPatterns("/**")
  27. .excludePathPatterns("/user/login")
  28. .order(2);
  29. // registry.addInterceptor(new RefreshInterceptor(hashOperations,redisTemplate))
  30. // .addPathPatterns("/**")
  31. // .order(1);
  32. }
  33. }