@Override @Transactional(readOnly = true) public MessageSend getMessageSend(Integer id) throws LogicException { MessageSend send = loadMessageSend(id); super.doAuthencation(UserContext.getUser(), send.getSender()); cleanMessageDetail(send.getDetail()); return send; }
@Override @Transactional(readOnly = true) public MessageReceive getMessageReceive(Integer id) throws LogicException { MessageReceive receive = loadMessageReceive(id); super.doAuthencation(UserContext.getUser(), receive.getReceiver()); cleanMessageDetail(receive.getMessage().getDetail()); return receive; }
@Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void updateMessageRecieveStatus(Set<Integer> receives, MessageStatus status) throws LogicException { for (Integer id : receives) { MessageReceive receive = loadMessageReceive(id); super.doAuthencation(UserContext.getUser(), receive.getReceiver()); if (!receive.getStatus().equals(status)) { receive.setStatus(status); messageReceiveDao.update(receive); } } }
@Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void deleteMessageSends(Set<Integer> sends) throws LogicException { for (Integer id : sends) { MessageSend send = loadMessageSend(id); super.doAuthencation(UserContext.getUser(), send.getSender()); messageSendDao.deleteById(id); if (MessageType.GLOBAL.equals(send.getType())) { deleteMessageSend(send); } } }
@Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void deleteMessageReceives(Set<Integer> receives) throws LogicException { for (Integer id : receives) { MessageReceive receive = loadMessageReceive(id); super.doAuthencation(UserContext.getUser(), receive.getReceiver()); messageReceiveDao.deleteById(id); if (!receive.getIsRead()) { addCount(receive.getReceiver(), -1); } } }
@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); }
@Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void updateIsRead(Set<Integer> receives, boolean isRead) throws LogicException { for (Integer id : receives) { MessageReceive receive = loadMessageReceive(id); super.doAuthencation(UserContext.getUser(), receive.getReceiver()); boolean _isRead = receive.getIsRead(); if (!Boolean.valueOf(receive.getIsRead()).equals(isRead)) { receive.setIsRead(isRead); messageReceiveDao.update(receive); } if (!_isRead && isRead) { addCount(receive.getReceiver(), -1); } if (_isRead && !isRead) { addCount(receive.getReceiver(), 1); } } }