@Override
  public String intercept(ActionInvocation invocation) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    Map<String, String[]> params = request.getParameterMap();

    String result = invocation.invoke();

    HttpSession session = request.getSession();

    Object userObj = session.getAttribute("sysUser");
    if (userObj == null || !(userObj instanceof AdminUser)) {
      return result;
    }

    adminLog = createLogBean(params);

    if (ActionSupport.SUCCESS.equalsIgnoreCase(result)) {
      adminLog.setResult(1);
    } else if (ActionSupport.INPUT.equalsIgnoreCase(result)) {
      adminLog.setResult(2);
    } else if (ActionSupport.ERROR.equalsIgnoreCase(result)) {
      adminLog.setResult(3);
    } else if ("limit".equalsIgnoreCase(result)) {
      adminLog.setResult(4);
    }

    WebApplicationContext webApplicationContext =
        WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
    logService = webApplicationContext.getBean("logService", AdminLogService.class);

    TaskController.createTaskAndRun(
        new Task() {
          @Override
          public void run() {
            adminLog.setOperTime(new Timestamp(new Date().getTime()));
            logService.add(adminLog);
          }
        });

    return result;
  }
  private AdminLog createLogBean(Map<String, String[]> params) {
    AdminLog adminLog = new AdminLog();

    HttpSession session = ServletActionContext.getRequest().getSession();
    HttpServletRequest request = ServletActionContext.getRequest();

    String path = request.getServletPath();

    int serverId = 0;
    Object serverIdObj = session.getAttribute("serverId");
    if (serverIdObj != null) {
      serverId = Integer.parseInt(serverIdObj.toString());
    }

    int agentId = 0;
    Object agentIdObj = session.getAttribute("agent");
    if (agentIdObj != null) {
      agentId = Integer.parseInt(agentIdObj.toString());
    }

    AdminUser user = null;
    Object userObj = session.getAttribute("sysUser");
    if (userObj != null && userObj instanceof AdminUser) {
      user = (AdminUser) userObj;
    }

    AdminLogDesc logDesc = new AdminLogDesc();
    logDesc.setUserId(user.getId());
    logDesc.setAgentId(agentId);
    logDesc.setServerId(serverId);
    logDesc.setOperation(path);
    logDesc.setArgs(params);
    String operDesc = JsonUtil.beanToJson(logDesc);

    adminLog.setUserId(user.getId());
    adminLog.setOperation(path);
    adminLog.setOperDesc(operDesc);

    return adminLog;
  }