From 5188d56b4aa85743b10ef4feb595295ad5cb9b90 Mon Sep 17 00:00:00 2001
From: 若依 <yzz_ivy@163.com>
Date: Sat, 18 Sep 2021 18:41:03 +0800
Subject: [PATCH] !321 修复 全局限流key会多出一个"-" 将其移动到IP后面 去除多余的空格 Merge pull request !321 from 疯狂的狮子Li/N/A
---
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
index 4f3de4a..97c2490 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
@@ -16,6 +16,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
+import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.HandlerMapping;
import com.alibaba.fastjson.JSON;
@@ -26,10 +27,9 @@
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
-import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
-import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysOperLog;
/**
@@ -84,7 +84,7 @@
}
// 获取当前的用户
- LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+ LoginUser loginUser = SecurityUtils.getLoginUser();
// *========数据库日志=========*//
SysOperLog operLog = new SysOperLog();
@@ -92,9 +92,6 @@
// 请求的地址
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
operLog.setOperIp(ip);
- // 返回参数
- operLog.setJsonResult(JSON.toJSONString(jsonResult));
-
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (loginUser != null)
{
@@ -113,7 +110,7 @@
// 设置请求方式
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
// 处理设置注解上的参数
- getControllerMethodDescription(joinPoint, controllerLog, operLog);
+ getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
// 保存数据库
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
}
@@ -133,7 +130,7 @@
* @param operLog 操作日志
* @throws Exception
*/
- public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception
+ public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception
{
// 设置action动作
operLog.setBusinessType(log.businessType().ordinal());
@@ -146,6 +143,11 @@
{
// 获取参数的信息,传入到数据库中。
setRequestValue(joinPoint, operLog);
+ }
+ // 是否需要保存response,参数和值
+ if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
+ {
+ operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
}
}
@@ -196,7 +198,7 @@
{
for (int i = 0; i < paramsArray.length; i++)
{
- if (!isFilterObject(paramsArray[i]))
+ if (StringUtils.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i]))
{
Object jsonObj = JSON.toJSON(paramsArray[i]);
params += jsonObj.toString() + " ";
@@ -237,6 +239,7 @@
return entry.getValue() instanceof MultipartFile;
}
}
- return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse;
+ return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
+ || o instanceof BindingResult;
}
}
--
Gitblit v1.9.2