防重复提交标识组合(key + url + header)

This commit is contained in:
RuoYi 2021-12-30 14:15:10 +08:00
parent 5bd0a43d05
commit a9f0852947

View File

@ -58,16 +58,12 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
// 请求地址作为存放cache的key值 // 请求地址作为存放cache的key值
String url = request.getRequestURI(); String url = request.getRequestURI();
// 唯一值没有消息头则使用请求地址
String submitKey = request.getHeader(header);
if (StringUtils.isEmpty(submitKey))
{
submitKey = url;
}
// 唯一标识指定key + 消息头 // 唯一值没有消息头则使用请求地址
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey; String submitKey = StringUtils.trimToEmpty(request.getHeader(header));
// 唯一标识指定key + url + 消息头
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
Object sessionObj = redisCache.getCacheObject(cacheRepeatKey); Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
if (sessionObj != null) if (sessionObj != null)