From 9639c096baaac61e28b23b43e6df0e3993a218ab Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期五, 27 五月 2022 17:50:49 +0800
Subject: [PATCH] 用户列表查询不显示密码字段
---
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java | 37 ++++++-------------------------------
1 files changed, 6 insertions(+), 31 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
index fd456b0..7b8ccf1 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
@@ -4,10 +4,8 @@
import java.util.Collections;
import java.util.List;
import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
-import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -49,16 +47,9 @@
this.limitScript = limitScript;
}
- // 配置织入点
- @Pointcut("@annotation(com.ruoyi.common.annotation.RateLimiter)")
- public void rateLimiterPointCut()
+ @Before("@annotation(rateLimiter)")
+ public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable
{
- }
-
- @Before("rateLimiterPointCut()")
- public void doBefore(JoinPoint point) throws Throwable
- {
- RateLimiter rateLimiter = getAnnotationRateLimiter(point);
String key = rateLimiter.key();
int time = rateLimiter.time();
int count = rateLimiter.count();
@@ -70,7 +61,7 @@
Long number = redisTemplate.execute(limitScript, keys, count, time);
if (StringUtils.isNull(number) || number.intValue() > count)
{
- throw new ServiceException("访问过于频繁,请稍后再试");
+ throw new ServiceException("访问过于频繁,请稍候再试");
}
log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key);
}
@@ -80,24 +71,8 @@
}
catch (Exception e)
{
- throw new RuntimeException("服务器限流异常,请稍后再试");
+ throw new RuntimeException("服务器限流异常,请稍候再试");
}
- }
-
- /**
- * 是否存在注解,如果存在就获取
- */
- private RateLimiter getAnnotationRateLimiter(JoinPoint joinPoint)
- {
- Signature signature = joinPoint.getSignature();
- MethodSignature methodSignature = (MethodSignature) signature;
- Method method = methodSignature.getMethod();
-
- if (method != null)
- {
- return method.getAnnotation(RateLimiter.class);
- }
- return null;
}
public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)
@@ -105,12 +80,12 @@
StringBuffer stringBuffer = new StringBuffer(rateLimiter.key());
if (rateLimiter.limitType() == LimitType.IP)
{
- stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest()));
+ stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-");
}
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
Class<?> targetClass = method.getDeclaringClass();
- stringBuffer.append("-").append(targetClass.getName()).append("- ").append(method.getName());
+ stringBuffer.append(targetClass.getName()).append("-").append(method.getName());
return stringBuffer.toString();
}
}
--
Gitblit v1.9.2