use of com.hccake.ballcat.log.model.entity.OperationLog in project ballcat by ballcat-projects.
the class CustomOperationLogHandler method buildLog.
@Override
public OperationLog buildLog(OperationLogging operationLogging, ProceedingJoinPoint joinPoint) {
// 获取 Request
HttpServletRequest request = LogUtils.getHttpServletRequest();
// @formatter:off
OperationLog operationLog = new OperationLog().setCreateTime(LocalDateTime.now()).setIp(IpUtils.getIpAddr(request)).setMethod(request.getMethod()).setUserAgent(request.getHeader("user-agent")).setUri(URLUtil.getPath(request.getRequestURI())).setType(operationLogging.type().getValue()).setMsg(operationLogging.msg()).setParams(getParams(joinPoint)).setTraceId(MDC.get(LogConstant.TRACE_ID));
// @formatter:on
// 操作用户
User user = SecurityUtils.getUser();
if (user != null) {
operationLog.setOperator(user.getUsername());
}
return operationLog;
}
Aggregations