Commit 5d35d690 by fsn

日志记录改为先执行业务,在记录日志

parent ff45adbb
...@@ -42,6 +42,19 @@ public class LogAop { ...@@ -42,6 +42,19 @@ public class LogAop {
@Around("cutService()") @Around("cutService()")
public Object recordSysLog(ProceedingJoinPoint point) throws Throwable { public Object recordSysLog(ProceedingJoinPoint point) throws Throwable {
//先执行业务
Object result = point.proceed();
try {
handle(point);
} catch (Exception e) {
log.error("日志记录出错!", e);
}
return result;
}
private void handle(ProceedingJoinPoint point) throws Exception {
//获取拦截的方法名 //获取拦截的方法名
Signature sig = point.getSignature(); Signature sig = point.getSignature();
MethodSignature msig = null; MethodSignature msig = null;
...@@ -56,7 +69,7 @@ public class LogAop { ...@@ -56,7 +69,7 @@ public class LogAop {
//如果当前用户未登录,不做日志 //如果当前用户未登录,不做日志
ShiroUser user = ShiroKit.getUser(); ShiroUser user = ShiroKit.getUser();
if (null == user) { if (null == user) {
return point.proceed(); return;
} }
//获取拦截方法的参数 //获取拦截方法的参数
...@@ -84,15 +97,14 @@ public class LogAop { ...@@ -84,15 +97,14 @@ public class LogAop {
} else { } else {
Map<String, String> parameters = HttpKit.getRequestParameters(); Map<String, String> parameters = HttpKit.getRequestParameters();
String value = parameters.get(key); String value = parameters.get(key);
if(ToolUtil.isNotEmpty(value)){ if (ToolUtil.isNotEmpty(value)) {
AbstractDictMap dictMap = DictMapFactory.createDictMap(dictClass); AbstractDictMap dictMap = DictMapFactory.createDictMap(dictClass);
msg = dictMap.get(key) + ":" + value; msg = dictMap.get(key) + ":" + value;
}else{ } else {
msg = "无"; msg = "无";
} }
} }
LogManager.me().executeLog(LogTaskFactory.bussinessLog(user.getId(), bussinessName, className, methodName, msg)); LogManager.me().executeLog(LogTaskFactory.bussinessLog(user.getId(), bussinessName, className, methodName, msg));
return point.proceed();
} }
} }
\ 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