Пример #1
0
  @AfterReturning(
      value = "@annotation(com.kcp.platform.common.log.annotation.Log)",
      returning = "returnVal")
  public void logAfterReturning(JoinPoint pjp, Object returnVal) throws Throwable {
    try {
      if (pjp.toLongString().equals(SqlContextHolder.getJoinPoint())) {
        MethodSignature joinPointObject = (MethodSignature) pjp.getSignature();
        Method method = joinPointObject.getMethod();
        MethodSysLogDefinition definition = parser.parseLogAnnotation(method);

        String logType = definition.getType();
        String moduleName = definition.getModuleName();
        String operateDesc = definition.getOperateDesc();
        String operateContent = SqlContextHolder.getSql();
        if (definition.isUseSpel()) {
          /** 对日志描述和日志备注加入SPEL支持 */
          LogOperationContext context =
              getOperationContext(definition, method, pjp.getArgs(), pjp.getClass());
          operateDesc = context.desc();
        }
        Logger.getInstance().addSysLog(logType, operateContent, moduleName, operateDesc);
        SqlContextHolder.clear();
      }
    } catch (Exception e) {
      logger.error("记录系统操作日志失败", e);
    }
  }
Пример #2
0
 @Before(value = "execution(* com.kcp*..*Service.*(..))")
 public void clearBeforeExcute(JoinPoint pjp) {
   if (StringUtils.isEmpty(SqlContextHolder.getJoinPoint())) {
     // 清空sql上下文信息
     SqlContextHolder.clear();
     SqlContextHolder.setJoinPoint(pjp.toLongString());
   }
 }
Пример #3
0
 @AfterReturning(value = "execution(* com.kcp*..*Service.*(..))")
 public void clearAfterReturning(JoinPoint pjp) throws Throwable {
   if (pjp.toLongString().equals(SqlContextHolder.getJoinPoint())) {
     SqlContextHolder.clearJoinPoint();
   }
 }