Search in sources :

Example 1 with SysOperLog

use of com.ruoyi.system.domain.SysOperLog in project wumei-smart by kerwincui.

the class LogAspect method handleLog.

protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
    try {
        // 获取当前的用户
        LoginUser loginUser = SecurityUtils.getLoginUser();
        // *========数据库日志=========*//
        SysOperLog operLog = new SysOperLog();
        operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
        // 请求的地址
        String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
        operLog.setOperIp(ip);
        operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
        if (loginUser != null) {
            operLog.setOperName(loginUser.getUsername());
        }
        if (e != null) {
            operLog.setStatus(BusinessStatus.FAIL.ordinal());
            operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
        }
        // 设置方法名称
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = joinPoint.getSignature().getName();
        operLog.setMethod(className + "." + methodName + "()");
        // 设置请求方式
        operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
        // 处理设置注解上的参数
        getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
        // 保存数据库
        AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
    } catch (Exception exp) {
        // 记录本地异常日志
        log.error("==前置通知异常==");
        log.error("异常信息:{}", exp.getMessage());
        exp.printStackTrace();
    }
}
Also used : SysOperLog(com.ruoyi.system.domain.SysOperLog) LoginUser(com.ruoyi.common.core.domain.model.LoginUser)

Example 2 with SysOperLog

use of com.ruoyi.system.domain.SysOperLog in project RuoYi-Vue-Plus by JavaLionLi.

the class SysOperLogServiceImpl method recordOper.

/**
 * 操作日志记录
 *
 * @param operLogDTO 操作日志信息
 */
@Async
@Override
public void recordOper(final OperLogDTO operLogDTO) {
    SysOperLog operLog = BeanUtil.toBean(operLogDTO, SysOperLog.class);
    // 远程查询操作地点
    operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
    insertOperlog(operLog);
}
Also used : SysOperLog(com.ruoyi.system.domain.SysOperLog) Async(org.springframework.scheduling.annotation.Async)

Example 3 with SysOperLog

use of com.ruoyi.system.domain.SysOperLog in project RuoYi-Flowable-Plus by KonBAI-Q.

the class SysOperLogServiceImpl method recordOper.

/**
 * 操作日志记录
 *
 * @param operLogDTO 操作日志信息
 */
@Async
@Override
public void recordOper(final OperLogDTO operLogDTO) {
    SysOperLog operLog = BeanUtil.toBean(operLogDTO, SysOperLog.class);
    // 远程查询操作地点
    operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
    insertOperlog(operLog);
}
Also used : SysOperLog(com.ruoyi.system.domain.SysOperLog) Async(org.springframework.scheduling.annotation.Async)

Example 4 with SysOperLog

use of com.ruoyi.system.domain.SysOperLog in project RuoYi-Vue by yangzongzhuan.

the class LogAspect method handleLog.

protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
    try {
        // 获取当前的用户
        LoginUser loginUser = SecurityUtils.getLoginUser();
        // *========数据库日志=========*//
        SysOperLog operLog = new SysOperLog();
        operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
        // 请求的地址
        String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
        operLog.setOperIp(ip);
        operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
        if (loginUser != null) {
            operLog.setOperName(loginUser.getUsername());
        }
        if (e != null) {
            operLog.setStatus(BusinessStatus.FAIL.ordinal());
            operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
        }
        // 设置方法名称
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = joinPoint.getSignature().getName();
        operLog.setMethod(className + "." + methodName + "()");
        // 设置请求方式
        operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
        // 处理设置注解上的参数
        getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
        // 保存数据库
        AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
    } catch (Exception exp) {
        // 记录本地异常日志
        log.error("==前置通知异常==");
        log.error("异常信息:{}", exp.getMessage());
        exp.printStackTrace();
    }
}
Also used : SysOperLog(com.ruoyi.system.domain.SysOperLog) LoginUser(com.ruoyi.common.core.domain.model.LoginUser)

Example 5 with SysOperLog

use of com.ruoyi.system.domain.SysOperLog in project hocassian-media-matrix by hokaso.

the class LogAspect method handleLog.

protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult) {
    try {
        // 获得注解
        Log controllerLog = getAnnotationLog(joinPoint);
        if (controllerLog == null) {
            return;
        }
        // 获取当前的用户
        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
        // *========数据库日志=========*//
        SysOperLog operLog = new SysOperLog();
        operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
        // 请求的地址
        String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
        operLog.setOperIp(ip);
        // 返回参数
        operLog.setJsonResult(JSON.toJSONString(jsonResult));
        operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
        if (loginUser != null) {
            operLog.setOperName(loginUser.getUsername());
        }
        if (e != null) {
            operLog.setStatus(BusinessStatus.FAIL.ordinal());
            operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
        }
        // 设置方法名称
        String className = joinPoint.getTarget().getClass().getName();
        String methodName = joinPoint.getSignature().getName();
        operLog.setMethod(className + "." + methodName + "()");
        // 设置请求方式
        operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
        // 处理设置注解上的参数
        getControllerMethodDescription(joinPoint, controllerLog, operLog);
        // 保存数据库
        AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
    } catch (Exception exp) {
        // 记录本地异常日志
        log.error("==前置通知异常==");
        log.error("异常信息:{}", exp.getMessage());
        exp.printStackTrace();
    }
}
Also used : SysOperLog(com.ruoyi.system.domain.SysOperLog) Log(com.ruoyi.common.annotation.Log) SysOperLog(com.ruoyi.system.domain.SysOperLog) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) TokenService(com.ruoyi.framework.web.service.TokenService)

Aggregations

SysOperLog (com.ruoyi.system.domain.SysOperLog)5 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)3 Async (org.springframework.scheduling.annotation.Async)2 Log (com.ruoyi.common.annotation.Log)1 TokenService (com.ruoyi.framework.web.service.TokenService)1