From 7b55e2cd82647b87d79a778ed70fdbddb39ac00a Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期二, 24 九月 2024 13:44:26 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java index 6aa40ff..bf60f1c 100644 --- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java +++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java @@ -1,5 +1,6 @@ package com.ruoyi.gateway.filter; +import com.ruoyi.gateway.config.properties.AntiShakeProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -39,9 +40,12 @@ // 排除过滤的 uri 地址,nacos自行添加 @Autowired private IgnoreWhiteProperties ignoreWhite; + @Autowired + private AntiShakeProperties antiShakeProperties; @Autowired private RedisService redisService; + @@ -59,7 +63,7 @@ try { antiShake(request); }catch (Exception e){ - log.error("[重复提交]请求路径:{}", exchange.getRequest().getPath()); + log.error(e.getMessage()); return ServletUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage(), HttpStatus.SUCCESS); } @@ -129,7 +133,7 @@ */ public void antiShake(ServerHttpRequest request) throws Exception{ HttpMethod method = request.getMethod(); - if(HttpMethod.OPTIONS == method){ + if(HttpMethod.OPTIONS == method || !antiShakeProperties.getEnable()){ return; } HttpHeaders headers = request.getHeaders(); @@ -155,8 +159,8 @@ Long old_timestamp = Long.valueOf(o.toString()); Long new_timestamp = Long.valueOf(timestamp); //两个请求时间差小于1秒,判定为重复提交 - if((new_timestamp - old_timestamp) <= 500){ - throw new RuntimeException("重复提交"); + if((new_timestamp - old_timestamp) <= antiShakeProperties.getInterval()){ + throw new RuntimeException(url + "----->重复提交"); }else{ cacheMap.put(url, timestamp); } -- Gitblit v1.7.1