@Override @Transactional(rollbackFor = Exception.class, propagation = Propagation.NESTED) public void sendTip(TipMessage message) { if (message.getSender().equals(message.getReceiver())) { return; } MessageDetail detail = new MessageDetail(message.getTitle(), message.getContent()); messageDetailDao.insert(detail); MessageSend toSend = new MessageSend(); toSend.setDetail(detail); toSend.setSendDate(new Date()); toSend.setSender(message.getSender()); toSend.setType(MessageType.SYSTEM); messageSendDao.insert(toSend); MessageReceive toReceive = new MessageReceive(); toReceive.setMessage(toSend); toReceive.setReceiver(message.getReceiver()); toReceive.setStatus(MessageStatus.COMMON); messageReceiveDao.insert(toReceive); addCount(message.getReceiver(), 1); }
@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(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(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); }