chore: 优化IP访问限制配置的命名

This commit is contained in:
ray
2024-08-10 17:37:20 +08:00
parent b61e57e132
commit fa5a944511
4 changed files with 6 additions and 6 deletions

View File

@@ -24,8 +24,8 @@ public interface SystemConstants {
String ROOT_ROLE_CODE = "ROOT";
/**
* IP请求限制QPS阈值配置KEY
* 单个IP请求的最大每秒查询数(QPS阈值Key
*/
String CONFIG_IP_RATE_LIMIT_QPS_KEY = "IP_RATE_LIMIT_COUNT_QPS";
String IP_QPS_THRESHOLD_LIMIT_KEY = "IP_QPS_THRESHOLD_LIMIT";
}

View File

@@ -49,13 +49,13 @@ public class RedisRateLimiterFilter extends OncePerRequestFilter {
if (count == null || count == 1) {
redisTemplate.expire(key,1, TimeUnit.SECONDS);
}
Object systemConfig = sysConfigService.getSystemConfig(SystemConstants.CONFIG_IP_RATE_LIMIT_QPS_KEY);
Object systemConfig = sysConfigService.getSystemConfig(SystemConstants.IP_QPS_THRESHOLD_LIMIT_KEY);
long limit = 10;
if(systemConfig != null){
limit = Long.parseLong(systemConfig.toString());
}else{
log.warn("[RedisRateLimiterFilter.rateLimit]系统配置中未配置IP请求限制QPS阈值配置,使用默认值:{},请检查配置项:{}",
limit,SystemConstants.CONFIG_IP_RATE_LIMIT_QPS_KEY);
limit,SystemConstants.IP_QPS_THRESHOLD_LIMIT_KEY);
}
return count != null && count > limit;
}