频率限制7

This commit is contained in:
GYJ
2025-03-23 17:20:48 +08:00
parent 09ece58a42
commit 8ea8cf1dcd
4 changed files with 10 additions and 2 deletions

View File

@@ -2,7 +2,9 @@ package com.sqx.common.aspect;
import com.google.common.util.concurrent.RateLimiter;
import com.sqx.common.annotation.Limiting;
import com.sqx.common.exception.CzgException;
import com.sqx.common.utils.IPUtils;
import com.sqx.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
@@ -56,7 +58,7 @@ public class RateLimitAspect {
} else {
// 未获取到许可,抛出异常或返回错误信息
log.info("IP: {} 请求方法: {} 超过访问频率限制", ip, method.getName());
throw new RuntimeException("访问频率过高,请稍后再试");
throw new CzgException("访问频率过高,请稍后再试");
}
}
}