Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-store
Commits
28288d92
Commit
28288d92
authored
Sep 25, 2020
by
zhiwj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打印参数
parent
6484775c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
ParamAOP.java
...e-service/src/main/java/com/gic/store/utils/ParamAOP.java
+64
-0
No files found.
gic-store-service/src/main/java/com/gic/store/utils/ParamAOP.java
0 → 100644
View file @
28288d92
package
com
.
gic
.
store
.
utils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.context.annotation.Configuration
;
import
java.lang.reflect.Method
;
/**
* 采集GIC系统操作日志
*
* @author leeon
* @date 2019年6月28日
*/
@Aspect
@Configuration
public
class
ParamAOP
{
private
Logger
logger
=
LogManager
.
getLogger
(
ParamAOP
.
class
);
/**
* 环绕通知
*
* @param joinPoint
* @return
* @throws Throwable
*/
@Around
(
value
=
"execution(* com.gic.store.service..*(..))"
)
public
Object
around
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
try
{
// 当前方法
Method
currentMethod
=
getCurrentMethod
(
joinPoint
);
// 当前方法参数列表
Object
[]
args
=
joinPoint
.
getArgs
();
logger
.
info
(
"请求方法:{}, 参数:{}"
,
currentMethod
.
getName
(),
args
);
// 执行当前方法
return
joinPoint
.
proceed
();
}
catch
(
Throwable
throwable
)
{
logger
.
warn
(
"拦截器错误"
,
throwable
);
throw
throwable
;
}
}
/**
* 获取当前方法
*
* @param joinPoint
* @return
* @throws
*/
private
Method
getCurrentMethod
(
ProceedingJoinPoint
joinPoint
)
throws
NoSuchMethodException
{
Signature
signature
=
joinPoint
.
getSignature
();
MethodSignature
methodSignature
=
(
MethodSignature
)
signature
;
Object
target
=
joinPoint
.
getTarget
();
return
target
.
getClass
().
getMethod
(
methodSignature
.
getName
(),
methodSignature
.
getParameterTypes
());
}
}
\ No newline at end of file
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