|
|
@@ -1,11 +1,17 @@
|
|
|
package com.roma.romaapi.config;
|
|
|
|
|
|
import com.roma.romaapi.interceptor.JWTInterceptor;
|
|
|
+import com.roma.romaapi.service.PageService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 拦截器的配置文件
|
|
|
*/
|
|
|
@@ -13,11 +19,31 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
@Configuration
|
|
|
public class InterceptorConfig implements WebMvcConfigurer {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate<String, String> redisTemplate;
|
|
|
+ @Autowired
|
|
|
+ PageService pageService;
|
|
|
@Autowired
|
|
|
private JWTInterceptor jwtInterceptor;
|
|
|
+ @Value("${spring.redis.host}")
|
|
|
+ private String redisHost;
|
|
|
+
|
|
|
+ @Value("${spring.redis.port}")
|
|
|
+ private String redisPort;
|
|
|
+
|
|
|
+ @Value("${spring.redis.password}")
|
|
|
+ private String redisPassword;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
|
+// System.out.println("-----redisHost------"+redisHost);
|
|
|
+// System.out.println("-----redisPort------"+redisPort);
|
|
|
+// System.out.println("-----redisPassword------"+redisPassword);
|
|
|
+// String captchaTokenValue = redisTemplate.opsForValue().get("dsdsdsds"); // 缓存中验证码的值
|
|
|
+// System.out.println("---调用redis缓存---"+captchaTokenValue);
|
|
|
+// List pages = pageService.menu();
|
|
|
+// System.out.println("---shujuku---"+pages);
|
|
|
registry.addInterceptor(jwtInterceptor)
|
|
|
//拦截的路径
|
|
|
.addPathPatterns("/**")
|