From 16372254d21ae39979001c4401c74d1ef89f1cd2 Mon Sep 17 00:00:00 2001 From: Gary Date: Tue, 27 Feb 2024 23:12:00 +0800 Subject: [PATCH] 1.fix checkRequestFrequency leak --- .../main/java/com/luoo/user/aspect/OperationAspect.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/aspect/OperationAspect.java b/luoo_user/src/main/java/com/luoo/user/aspect/OperationAspect.java index 71ec7b5..ee64ac7 100644 --- a/luoo_user/src/main/java/com/luoo/user/aspect/OperationAspect.java +++ b/luoo_user/src/main/java/com/luoo/user/aspect/OperationAspect.java @@ -85,9 +85,7 @@ public class OperationAspect { } private void checkRequestFrequency(String fullMethodName, RequestFrequencyTypeEnum frequencyTyp, Integer threshold) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String ip = getIpAddr(request); - ip = ip.replace(":", ""); - String redisKey = fullMethodName + ip; + String redisKey = fullMethodName + getKey(request); Object count=redisUtils.get(redisKey); Integer cuCount= null==count?0:Integer.valueOf((String)count); if (cuCount != null && cuCount > threshold - 1) { @@ -95,6 +93,10 @@ public class OperationAspect { } redisUtils.increment(redisKey, 1, frequencyTyp.getSeconds()); } + private String getKey(HttpServletRequest request) { + String mobile = request.getParameter("mobile"); + return StringTools.isEmpty(mobile)?getIpAddr(request).replace(":", ""): mobile; + } private void checkAppUserLogin() { UserLoginDto userLoginDto = getUserLoginDtoFromToken(); if (userLoginDto == null) {