@Transactional public Chat update(int id, String messages) { Chat chat = new Chat(); chat = chatDao.findOne(id); chat.setMessages(messages); Chat result = chatDao.save(chat); return result; }
@Transactional public Chat postImage(int userId, String picture) { Chat result = null; Chat chat = new Chat(); User user = (User) userDao.findOne(userId); chat.setUser(user); chat.setPicture(picture); chat.setSendTime(LocalDateTime.now(ZoneId.of("UTC+8"))); result = chatDao.save(chat); return result; }
@Transactional public Chat postChat(int userId, String messages, Character showUserInfo) { Chat result = null; Chat chat = new Chat(); User user = (User) userDao.findOne(userId); chat.setMessages(messages); chat.setShowUserInfo(showUserInfo); chat.setUser(user); chat.setSendTime(LocalDateTime.now(ZoneId.of("UTC+8"))); result = chatDao.save(chat); return result; }
@Transactional public List<Chat> getLastThreeChats() { List<Chat> chats = chatDao.findAllOrderBySendTime(); return chats; }