update 防重复提交标识组合 改为 key + url + header

This commit is contained in:
疯狂的狮子li 2022-01-11 12:36:33 +08:00
parent 9bad713db5
commit fc8c96399f

View File

@ -57,13 +57,11 @@ public class RepeatSubmitAspect {
String url = request.getRequestURI();
// 唯一值没有消息头则使用请求地址
String submitKey = request.getHeader(tokenProperties.getHeader());
if (StringUtils.isEmpty(submitKey)) {
submitKey = url;
}
String submitKey = StringUtils.trimToEmpty(request.getHeader(tokenProperties.getHeader()));
submitKey = SecureUtil.md5(submitKey + ":" + nowParams);
// 唯一标识指定key + 消息头
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + submitKey;
// 唯一标识指定key + url + 消息头
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
String key = RedisUtils.getCacheObject(cacheRepeatKey);
if (key == null) {
RedisUtils.setCacheObject(cacheRepeatKey, "", interval, TimeUnit.MILLISECONDS);