操作记录日志保存设计实现

定义一个切面类

@Aspect
@Slf4j
@Component
@RequiredArgsConstructor
public class OperateLogAopConfig {
    private final ISysOperateLogService sysOperateLogService;

    @Around("@annotation(operateLog)")
    public Object operateLog(ProceedingJoinPoint point, OperateLog operateLog) throws Throwable {
        final List params = getCanJsonParams(point);
        String status = "ready";
        try {
            Object result = point.proceed();
            status = "success";
            return result;
        } catch (Exception e) {
            status = "fail";
            throw e;
        }finally {
            saveOperateLog(operateLog.operateChannel(),operateLog.operateType(),null,operateLog.operateLog(), JSONObject.toJSONString(params),
                    operateLog.operateBefore(),operateLog.operateAfter(),status);
        }
    }

    @NotNull
    private 
  

                            
                        
                    
                    
                    

你可能感兴趣的:(系统架构设计,java,前端,服务器)