Esempio n. 1
0
  @Override
  @Transactional(readOnly = true)
  public Page<MessageReceive> findMessageReceives(MessageReceivePageParam param) {

    if (param.getSend() != null) {
      MessageSend send = messageSendDao.selectById(param.getSend().getId());
      if (send == null) {
        return new Page<MessageReceive>(param, 0, new ArrayList<MessageReceive>());
      }

      super.doAuthencation(UserContext.getUser(), send.getSender());
    }

    int total = messageReceiveDao.selectCount(param);
    List<MessageReceive> datas = messageReceiveDao.selectPage(param);
    return new Page<MessageReceive>(param, total, datas);
  }
Esempio n. 2
0
  @Override
  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  public int getToReadMessageCount(User user) {
    int unreadFromSources = handleGlobalMessage(user);
    Map<String, Object> map = (Map<String, Object>) messageCache.get(user.getId());
    if (map != null && map.containsKey(UNREAD_COUNT)) {
      int totalCount = (Integer) map.get(UNREAD_COUNT) + unreadFromSources;
      addCount(user, unreadFromSources);
      return totalCount;
    }

    MessageReceivePageParam param = new MessageReceivePageParam();
    param.setIsRead(false);
    param.setReceiver(user);
    int count = messageReceiveDao.selectCount(param);
    addCount(user, count);
    return count;
  }