fix(LimitAspect): 使用ObjUtil优化空值判断

pull/827/merge
Jie Zheng 2025-01-15 09:26:29 +08:00
parent 7d32b7bad6
commit a14d2c4324
1 changed files with 2 additions and 1 deletions

View File

@ -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;
@ -73,7 +74,7 @@ public class LimitAspect {
String luaScript = buildLuaScript();
RedisScript<Long> redisScript = new DefaultRedisScript<>(luaScript, Long.class);
Long count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period());
if (null != count && count.intValue() <= limit.count()) {
if (ObjUtil.isNotNull(count) && count.intValue() <= limit.count()) {
logger.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name());
return joinPoint.proceed();
} else {