Search in sources :

Example 1 with OperationLog

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;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) User(com.hccake.ballcat.common.security.userdetails.User) OperationLog(com.hccake.ballcat.log.model.entity.OperationLog)

Aggregations

User (com.hccake.ballcat.common.security.userdetails.User)1 OperationLog (com.hccake.ballcat.log.model.entity.OperationLog)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1