This commit is contained in:
张良(004796)
2024-01-17 15:38:38 +08:00
parent 2903719ea6
commit d8f0845518

View File

@@ -84,11 +84,15 @@ public class LogAspect {
// 设置请求方式
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
logString.append(String.format("url=%s;method=%s;title=%s;",operLog.getOperUrl(),operLog.getRequestMethod(),controllerLog.title()));
LoginUser loginUser = LoginHelper.getLoginUser();
if(loginUser != null){
operLog.setOperName(loginUser.getUsername());
operLog.setUserType(loginUser.getUserType());
operLog.setDeptName(loginUser.getDeptName());
try {
LoginUser loginUser = LoginHelper.getLoginUser();
if(loginUser != null){
operLog.setOperName(loginUser.getUsername());
operLog.setUserType(loginUser.getUserType());
operLog.setDeptName(loginUser.getDeptName());
}
}catch (Exception ex){
// not do
}
// 处理设置注解上的参数
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult,logString);
@@ -97,8 +101,11 @@ public class LogAspect {
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
logString.append(String.format("exception=%s;",e.getMessage()));
}
log.info(logString.toString());
// 发布事件保存数据库
SpringUtils.context().publishEvent(operLog);
if(controllerLog.isSaveDb()){
SpringUtils.context().publishEvent(operLog);
}
} catch (Exception exp) {
// 记录本地异常日志
log.error("异常信息:{}", exp.getMessage());