Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
23270c60
Commit
23270c60
authored
Sep 16, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志注解新增是否保存响应参数
parent
2cb67093
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java
...common/src/main/java/com/ruoyi/common/annotation/Log.java
+5
-0
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
.../src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
+7
-5
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java
View file @
23270c60
...
@@ -38,4 +38,9 @@ public @interface Log
...
@@ -38,4 +38,9 @@ public @interface Log
* 是否保存请求的参数
* 是否保存请求的参数
*/
*/
public
boolean
isSaveRequestData
()
default
true
;
public
boolean
isSaveRequestData
()
default
true
;
/**
* 是否保存响应的参数
*/
public
boolean
isSaveResponseData
()
default
true
;
}
}
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
View file @
23270c60
...
@@ -92,9 +92,6 @@ public class LogAspect
...
@@ -92,9 +92,6 @@ public class LogAspect
// 请求的地址
// 请求的地址
String
ip
=
IpUtils
.
getIpAddr
(
ServletUtils
.
getRequest
());
String
ip
=
IpUtils
.
getIpAddr
(
ServletUtils
.
getRequest
());
operLog
.
setOperIp
(
ip
);
operLog
.
setOperIp
(
ip
);
// 返回参数
operLog
.
setJsonResult
(
JSON
.
toJSONString
(
jsonResult
));
operLog
.
setOperUrl
(
ServletUtils
.
getRequest
().
getRequestURI
());
operLog
.
setOperUrl
(
ServletUtils
.
getRequest
().
getRequestURI
());
if
(
loginUser
!=
null
)
if
(
loginUser
!=
null
)
{
{
...
@@ -113,7 +110,7 @@ public class LogAspect
...
@@ -113,7 +110,7 @@ public class LogAspect
// 设置请求方式
// 设置请求方式
operLog
.
setRequestMethod
(
ServletUtils
.
getRequest
().
getMethod
());
operLog
.
setRequestMethod
(
ServletUtils
.
getRequest
().
getMethod
());
// 处理设置注解上的参数
// 处理设置注解上的参数
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
);
getControllerMethodDescription
(
joinPoint
,
controllerLog
,
operLog
,
jsonResult
);
// 保存数据库
// 保存数据库
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordOper
(
operLog
));
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordOper
(
operLog
));
}
}
...
@@ -133,7 +130,7 @@ public class LogAspect
...
@@ -133,7 +130,7 @@ public class LogAspect
* @param operLog 操作日志
* @param operLog 操作日志
* @throws Exception
* @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动作
// 设置action动作
operLog
.
setBusinessType
(
log
.
businessType
().
ordinal
());
operLog
.
setBusinessType
(
log
.
businessType
().
ordinal
());
...
@@ -147,6 +144,11 @@ public class LogAspect
...
@@ -147,6 +144,11 @@ public class LogAspect
// 获取参数的信息,传入到数据库中。
// 获取参数的信息,传入到数据库中。
setRequestValue
(
joinPoint
,
operLog
);
setRequestValue
(
joinPoint
,
operLog
);
}
}
// 是否需要保存response,参数和值
if
(
log
.
isSaveResponseData
()
&&
StringUtils
.
isNotNull
(
jsonResult
))
{
operLog
.
setJsonResult
(
StringUtils
.
substring
(
JSON
.
toJSONString
(
jsonResult
),
0
,
2000
));
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment