diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimit.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimit.java index c41fb3d..08f8f7a 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimit.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimit.java @@ -13,5 +13,5 @@ public @interface AccessLimit { int seconds(); // 最大次数 - int maxCount(); + long maxCount(); } \ No newline at end of file diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimitInterceptor.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimitInterceptor.java index 3fc6821..a35c39a 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimitInterceptor.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/AccessLimitInterceptor.java @@ -44,13 +44,11 @@ public class AccessLimitInterceptor extends HandlerInterceptorAdapter { return true; } int seconds = accessLimit.seconds(); - int maxCount = accessLimit.maxCount(); + long maxCount = accessLimit.maxCount(); String accessLimitKey = "Access_Limit_" + request.getRequestURI(); synchronized (accessLimitKey) { - Integer count = huahengRedisUtil.get(accessLimitKey, Integer.class); - if (count == null || count < maxCount) { - huahengRedisUtil.incr(accessLimitKey, seconds); - } else { + long count = huahengRedisUtil.incr(accessLimitKey, seconds); + if (count > maxCount) { log.error("{},超出访问频次限制。限制频次:{}秒{}次", request.getRequestURI(), maxCount, seconds); throw new JeecgBootException("超出访问频次限制"); }