Exemplo n.º 1
0
  /**
   * 记录操作日志,约定执行操作的这个方法第一个参数为业务Model,如 add(User)
   *
   * @param target 拦截的Service Class,如 UserService
   * @param method Service Class中的方法, 如UserService.add(User)这个方法
   * @param model 业务Model,如一个User类
   */
  private void log(Object target, Method method, Object model)
      throws SecurityException, IllegalArgumentException, IllegalAccessException,
          NoSuchMethodException, InvocationTargetException, ParseException {

    Date createTime = new Date();
    User opUser = Helper.getUser();
    String opName = method.getAnnotation(LoggerMethod.class).operateName();

    doLog(createTime, opUser, opName, (Model) model);
  }
Exemplo n.º 2
0
 private String getContents(Date createTime, String opUserName, String opName, Model model)
     throws ParseException {
   return Helper.toDateString(createTime)
       + " : "
       + "用户"
       + "<"
       + opUserName
       + ">"
       + opName
       + "了一条["
       + model
       + "]记录!";
 }