From 185c5e182a262f30edb633196032425aa9ed59c8 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期三, 05 八月 2020 14:24:06 +0800
Subject: [PATCH] 唯一限制条件只返回单条数据
---
src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
index 0a80dce..44e69e4 100644
--- a/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
+++ b/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
@@ -5,8 +5,10 @@
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpHelper;
@@ -26,7 +28,9 @@
public final String REPEAT_TIME = "repeatTime";
- public final String CACHE_REPEAT_KEY = "repeatData";
+ // 浠ょ墝鑷畾涔夋爣璇�
+ @Value("${token.header}")
+ private String header;
@Autowired
private RedisCache redisCache;
@@ -62,7 +66,10 @@
// 璇锋眰鍦板潃锛堜綔涓哄瓨鏀綾ache鐨刱ey鍊硷級
String url = request.getRequestURI();
- Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY);
+ // 鍞竴鏍囪瘑锛堟寚瀹歬ey + 娑堟伅澶达級
+ String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + request.getHeader(header);
+
+ Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
if (sessionObj != null)
{
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
@@ -77,7 +84,7 @@
}
Map<String, Object> cacheMap = new HashMap<String, Object>();
cacheMap.put(url, nowDataMap);
- redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS);
+ redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
return false;
}
--
Gitblit v1.9.3