Package com.github.dactiv.showcase.common.annotation

Examples of com.github.dactiv.showcase.common.annotation.OperatingAudit


  @Around("@annotation(com.github.dactiv.showcase.common.annotation.OperatingAudit)")
  public Object doAround(ProceedingJoinPoint point) throws Throwable {
   
    Method method = ((MethodSignature)point.getSignature()).getMethod();
   
    OperatingAudit audit = ReflectionUtils.getAnnotation(method, OperatingAudit.class);
   
    OperatingRecord record = new OperatingRecord();
    record.setStartDate(new Date());
    record.setMethod(method.getName());

    HttpServletRequest request = SpringMvcHolder.getRequest();
    StringBuffer sb = new StringBuffer();
   
    if(request != null) {
      record.setIp(getIpAddress(request));
      record.setOperatingTarget(request.getRequestURI());
      //获取本次提交的参数
      Map<String, Object> parameter = request.getParameterMap();
     
      if (parameter.size() > 0) {

        sb.append("<h2>request参数</h2>").append("<hr>");
        //逐个循环参数和值添加到操作记录参数的描述字段中
        for(Entry<String, Object> entry : parameter.entrySet()) {
          sb.append("<p>").
             append(entry.getKey()).
             append(":").
             append("<p>").
             append("<strong class='text-info'>").
             append(getParameterValue(entry.getValue())).
             append("</strong>").
             append("</p>");
        }
       
        sb.append("<hr>");
      }
    }
   
    //获取当前SessionVariable,通过该变量获取当前用户
    SessionVariable sessionVariable = SystemVariableUtils.getSessionVariable();
    //如果SessionVariable等于null,表示用户未登录,但一样要记录操作
    if (sessionVariable != null) {
      record.setFkUserId(sessionVariable.getUser().getId());
      record.setUsername(sessionVariable.getUser().getUsername());
    }
   
    String function = audit.function();
    String module = "";
   
    if (StringUtils.isEmpty(audit.value())) {
      OperatingAudit classAnnotation = ReflectionUtils.getAnnotation(method.getDeclaringClass(),OperatingAudit.class);
      module = classAnnotation == null ? "" : classAnnotation.value();
    }
   
    record.setFunction(function);
    record.setModule(module);
   
View Full Code Here

TOP

Related Classes of com.github.dactiv.showcase.common.annotation.OperatingAudit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.