|
@@ -5,8 +5,10 @@ import java.util.Map; |
|
@@ -5,8 +5,10 @@ import java.util.Map; |
|
5
|
import java.util.concurrent.TimeUnit;
|
5
|
import java.util.concurrent.TimeUnit;
|
|
6
|
import javax.servlet.http.HttpServletRequest;
|
6
|
import javax.servlet.http.HttpServletRequest;
|
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
8
|
+import org.springframework.beans.factory.annotation.Value;
|
|
8
|
import org.springframework.stereotype.Component;
|
9
|
import org.springframework.stereotype.Component;
|
|
9
|
import com.alibaba.fastjson.JSONObject;
|
10
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
11
|
+import com.ruoyi.common.constant.Constants;
|
|
10
|
import com.ruoyi.common.core.redis.RedisCache;
|
12
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
11
|
import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
|
13
|
import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
|
|
12
|
import com.ruoyi.common.utils.StringUtils;
|
14
|
import com.ruoyi.common.utils.StringUtils;
|
|
@@ -26,7 +28,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
@@ -26,7 +28,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
26
|
|
28
|
|
|
27
|
public final String REPEAT_TIME = "repeatTime";
|
29
|
public final String REPEAT_TIME = "repeatTime";
|
|
28
|
|
30
|
|
|
29
|
- public final String CACHE_REPEAT_KEY = "repeatData";
|
31
|
+ // 令牌自定义标识
|
|
|
|
32
|
+ @Value("${token.header}")
|
|
|
|
33
|
+ private String header;
|
|
30
|
|
34
|
|
|
31
|
@Autowired
|
35
|
@Autowired
|
|
32
|
private RedisCache redisCache;
|
36
|
private RedisCache redisCache;
|
|
@@ -62,7 +66,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
@@ -62,7 +66,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
62
|
// 请求地址(作为存放cache的key值)
|
66
|
// 请求地址(作为存放cache的key值)
|
|
63
|
String url = request.getRequestURI();
|
67
|
String url = request.getRequestURI();
|
|
64
|
|
68
|
|
|
65
|
- Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
|
69
|
+ // 唯一标识(指定key + 消息头)
|
|
|
|
70
|
+ String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + request.getHeader(header);
|
|
|
|
71
|
+
|
|
|
|
72
|
+ Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
|
|
66
|
if (sessionObj != null)
|
73
|
if (sessionObj != null)
|
|
67
|
{
|
74
|
{
|
|
68
|
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
|
75
|
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
|
|
@@ -77,7 +84,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
@@ -77,7 +84,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor |
|
77
|
}
|
84
|
}
|
|
78
|
Map<String, Object> cacheMap = new HashMap<String, Object>();
|
85
|
Map<String, Object> cacheMap = new HashMap<String, Object>();
|
|
79
|
cacheMap.put(url, nowDataMap);
|
86
|
cacheMap.put(url, nowDataMap);
|
|
80
|
- redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS);
|
87
|
+ redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
|
|
81
|
return false;
|
88
|
return false;
|
|
82
|
}
|
89
|
}
|
|
83
|
|
90
|
|