ip 请求次数限制20

This commit is contained in:
GYJ 2025-03-24 15:34:23 +08:00
parent 2f61455c7c
commit 9ef5c4aa8a
2 changed files with 6 additions and 6 deletions

View File

@ -13,5 +13,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface Limiting {
// 默认每秒放入桶中的token
double limitNum() default 2;
double limitNum() default 4;
}

View File

@ -54,11 +54,11 @@ public class AppApiMethodAspect {
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
String requestIp = IPUtils.getIpAddr(request);
Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
log.info("IpAccessCounter 一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
throw new LimitException("访问频率过高,请稍后再试");
}
// Integer maxAccessCount = Integer.parseInt(commonInfoService.findOne(935).getValue());
// if (!IpAccessCounter.canAccess(requestIp, maxAccessCount)) {
// log.info("IpAccessCounter 一分钟内请求超过限制IP: {}, 最大访问次数: {}", requestIp, maxAccessCount);
// throw new LimitException("访问频率过高,请稍后再试");
// }
String params = new Gson().toJson(args);