Commit 4a2eaf23 by guojuxing

Merge remote-tracking branch 'origin/developer' into developer

parents e080d85d 454005db
package com.gic.auth.config;
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;
/**
* 采集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.*.service..*(..))")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
try {
// 当前方法
String currentMethodName = getMethodName(joinPoint);
// 当前方法参数列表
Object[] args = joinPoint.getArgs();
logger.info("请求方法:{}, 参数:{}", currentMethodName, args);
// 执行当前方法
return joinPoint.proceed();
} catch (Throwable throwable) {
logger.warn("拦截器错误", throwable);
throw throwable;
}
}
/**
* 获取当前方法
*
* @param joinPoint
* @return
* @throws
*/
private String getMethodName(ProceedingJoinPoint joinPoint) throws NoSuchMethodException {
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Object target = joinPoint.getTarget();
return target.getClass().getName() + "." + methodSignature.getName();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment