Search in sources :

Example 1 with SysLogs

use of com.moon.admin.domain.SysLogs in project moon by gentoo111.

the class SysLogServiceImpl method save.

@Async
@Override
public void save(Long userId, String module, Boolean flag, String remark) {
    SysLogs sysLogs = new SysLogs();
    sysLogs.setFlag(flag);
    sysLogs.setModule(module);
    sysLogs.setRemark(remark);
    User user = new User();
    user.setId(userId);
    sysLogs.setUser(user);
    sysLogsDao.save(sysLogs);
}
Also used : User(com.moon.admin.domain.User) SysLogs(com.moon.admin.domain.SysLogs) Async(org.springframework.scheduling.annotation.Async)

Example 2 with SysLogs

use of com.moon.admin.domain.SysLogs in project moon by gentoo111.

the class LogAdvice method logSave.

@Around(value = "@annotation(com.moon.admin.common.utils.LogAnnotation)")
public Object logSave(ProceedingJoinPoint joinPoint) throws Throwable {
    SysLogs sysLogs = new SysLogs();
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    String module = null;
    LogAnnotation logAnnotation = methodSignature.getMethod().getDeclaredAnnotation(LogAnnotation.class);
    module = logAnnotation.module();
    if (StringUtils.isEmpty(module)) {
        ApiOperation apiOperation = methodSignature.getMethod().getDeclaredAnnotation(ApiOperation.class);
        if (apiOperation != null) {
            module = apiOperation.value();
        }
    }
    if (StringUtils.isEmpty(module)) {
        throw new RuntimeException("没有指定日志module");
    }
    sysLogs.setModule(module);
    try {
        Object object = joinPoint.proceed();
        sysLogs.setFlag(true);
        sysLogService.save(sysLogs);
        return object;
    } catch (Exception e) {
        sysLogs.setFlag(false);
        sysLogs.setRemark(e.getMessage());
        sysLogService.save(sysLogs);
        throw e;
    }
}
Also used : SysLogs(com.moon.admin.domain.SysLogs) MethodSignature(org.aspectj.lang.reflect.MethodSignature) ApiOperation(io.swagger.annotations.ApiOperation) Around(org.aspectj.lang.annotation.Around)

Aggregations

SysLogs (com.moon.admin.domain.SysLogs)2 User (com.moon.admin.domain.User)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Around (org.aspectj.lang.annotation.Around)1 MethodSignature (org.aspectj.lang.reflect.MethodSignature)1 Async (org.springframework.scheduling.annotation.Async)1