Пример #1
0
  public String getUnreadNotificationList() {
    if (!isUserLogined()) {
      plsLogin();
      return LOGIN;
    }

    String[] cacheKey =
        new String[] {CacheUtils.KEY_NOTIFICATION, new Integer(getCurUserId()).toString()};

    String cache = CacheUtils.get(cacheKey);
    if (cache != null) {
      setJson(cache);
    } else {

      List<Notification> list = getAccountMgr().getUnreadNotificationList(getCurUserId());
      List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
      for (Notification o : list) {
        Map<String, Object> m = new HashMap<String, Object>();
        m.put("id", o.getId());
        m.put("param1", o.getParam1());
        m.put("param2", o.getParam2());
        m.put("param3", o.getParam3());

        Map<String, Object> user = new HashMap<String, Object>();
        user.put("name", o.getUser().getName());
        user.put("id", o.getUser().getId());
        m.put("user", user);

        Map<String, Object> targetUser = new HashMap<String, Object>();
        targetUser.put("name", o.getTargetUser().getName());
        targetUser.put("id", o.getTargetUser().getId());

        m.put("targetUser", targetUser);

        m.put("createTime", o.getCreateTime().getTime());
        m.put("createTimeStr", o.getCreateTimeStr());
        m.put("typeId", o.getTypeId());
        result.add(m);
      }
      Gson gson = new Gson();
      String json = gson.toJson(result);
      setJson(json);
      CacheUtils.put(cacheKey, json, 60 * 10);
    }
    return SUCCESS;
  }
Пример #2
0
 public String readAllNotification() {
   if (!isUserLogined()) {
     plsLogin();
     return LOGIN;
   }
   getAccountMgr().readNotificationList(getCurUserId());
   String[] cacheKey =
       new String[] {CacheUtils.KEY_NOTIFICATION, new Integer(getCurUserId()).toString()};
   CacheUtils.del(cacheKey);
   return SUCCESS;
 }