Search in sources :

Example 1 with AdminOperationLog

use of com.ibeiliao.deployment.admin.vo.account.AdminOperationLog in project Corgi by kevinYin.

the class AdminLoggerAspect method processLog.

/**
 * 执行记录日志的操作
 *
 * @param jp
 * @param adminLog
 * @param result
 * @throws Exception
 */
private void processLog(JoinPoint jp, AdminLog adminLog, Object result) throws Exception {
    MethodSignature ms = (MethodSignature) jp.getSignature();
    Method method = ms.getMethod();
    // 日志类型,为空时取 MenuResource 的值
    String type = adminLog.type();
    if (StringUtils.isEmpty(type) && method.isAnnotationPresent(MenuResource.class)) {
        MenuResource menuResource = method.getAnnotation(MenuResource.class);
        type = menuResource.value();
    }
    if (doLog(adminLog, result)) {
        // 执行结果的信息
        String resultMessage = getResultMessage(adminLog, result);
        // 参数
        String arguments = getArguments(jp, method, adminLog);
        // ip
        // get admin id from AdminContext
        logger.info("参数列表 | admin: {}, type: {}, arguments: {}, result: {}", AdminContext.getAccountId(), type, arguments, resultMessage);
        // save log
        AdminLogger adminLogger = SpringContextUtil.getBean(AdminLogger.class);
        AdminOperationLog log = new AdminOperationLog();
        log.setOperationType(type);
        log.setResult(resultMessage);
        log.setArguments(arguments);
        log.setUid(AdminContext.getAccountId());
        adminLogger.saveAdminLog(log);
    } else {
        logger.info("DONT LOG ...............");
    }
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) Method(java.lang.reflect.Method) AdminOperationLog(com.ibeiliao.deployment.admin.vo.account.AdminOperationLog)

Aggregations

MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AdminOperationLog (com.ibeiliao.deployment.admin.vo.account.AdminOperationLog)1 Method (java.lang.reflect.Method)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1