From c474e0f3eeb58cfc7d9baea9654e11c20e858d71 Mon Sep 17 00:00:00 2001 From: Jie Zheng <201507802@qq.com> Date: Sat, 11 Jan 2025 10:28:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96LimitAspect=E4=B8=ADRe?= =?UTF-8?q?disScript=E7=B1=BB=E5=9E=8B=E5=8F=8AObjUtil=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20close=20https://github.com/elunez/eladmin-mp/issues/47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/zhengjie/aspect/LimitAspect.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/eladmin/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java b/eladmin/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java index 31f4040..63fb821 100644 --- a/eladmin/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java +++ b/eladmin/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java @@ -15,6 +15,7 @@ */ package me.zhengjie.aspect; +import cn.hutool.core.util.ObjUtil; import com.google.common.collect.ImmutableList; import me.zhengjie.annotation.Limit; import me.zhengjie.exception.BadRequestException; @@ -71,9 +72,9 @@ public class LimitAspect { ImmutableList keys = ImmutableList.of(StringUtils.join(limit.prefix(), "_", key, "_", request.getRequestURI().replace("/","_"))); String luaScript = buildLuaScript(); - RedisScript redisScript = new DefaultRedisScript<>(luaScript, Number.class); - Number count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period()); - if (null != count && count.intValue() <= limit.count()) { + RedisScript redisScript = new DefaultRedisScript<>(luaScript, Long.class); + Long count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period()); + if (ObjUtil.isNotNull(count) && count.intValue() <= limit.count()) { logger.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name()); return joinPoint.proceed(); } else {