use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.
the class TopicReplyDAOTest method testRemoveTopicReplyById.
/**
* 测试删除回复
*/
@Test
@Transactional
public void testRemoveTopicReplyById() {
TopicReplyDO reply = this.saveTestReplyToDatabase();
int replyId = reply.getId();
Assert.assertEquals(1, topicReplyDAO.removeTopicReplyById(replyId));
Assert.assertNull(topicReplyDAO.getTopicReplyById(replyId));
System.out.println("delete replyId=" + reply.getId() + " reply");
}
use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.
the class TopicServiceImpl method getTopicContentModelMap.
@Override
public Map<String, Object> getTopicContentModelMap(int topicId) {
TopicDO topic = this.getTopicNotNull(topicId);
TopicContentDO topicContent = this.getTopicContentNotNull(topicId);
TopicCategoryDO topicCategory = this.getTopicCategoryNotNullById(topic.getCategoryid());
UserDO topicAuthorUser = this.getUserNotNullById(topic.getUserid());
Map<String, Object> topicInfoMap = this.getTopicInfoMap(topic);
Map<String, Object> topicContentInfoMap = this.getTopicContentInfoMap(topicContent);
Map<String, Object> topicCategoryInfoMap = this.getTopicCategoryInfoMap(topicCategory);
Map<String, Object> authorUserInfoMap = this.getTopicUserInfoMap(topicAuthorUser);
Map<String, Object> lastReplyUserInfoMap = this.getTopicUserInfoMap(this.getUserNotNullById(topic.getLastreplyuserid()));
// get topic reply list, and add to map
List<TopicReplyDO> listReply = topicReplyDAO.listTopicReplyByTopicId(topicId);
List<Map<String, Object>> listReplyInfoMap = new ArrayList<>(listReply.size());
for (TopicReplyDO reply : listReply) {
Map<String, Object> replyInfoMap = this.getTopicReplyInfoMap(reply);
replyInfoMap.put(ParamConst.USER, this.getTopicUserInfoMap(userDAO.getUserById(reply.getUserid())));
listReplyInfoMap.add(replyInfoMap);
}
// merge all information map
topicInfoMap.putAll(topicContentInfoMap);
topicInfoMap.put(ParamConst.CATEGORY, topicCategoryInfoMap);
topicInfoMap.put(ParamConst.USER, authorUserInfoMap);
topicInfoMap.put(ParamConst.LAST_REPLY_USER, lastReplyUserInfoMap);
topicInfoMap.put(ParamConst.REPLY_LIST, listReplyInfoMap);
return topicInfoMap;
}
use of org.neusoft.neubbs.entity.TopicReplyDO in project neubbs by nuitcoder.
the class TopicServiceImpl method saveReply.
@Override
public Map<String, Object> saveReply(int userId, int topicId, String replyContent) {
this.getTopicNotNull(topicId);
// save topic reply
TopicReplyDO topicReply = new TopicReplyDO();
topicReply.setUserid(userId);
topicReply.setTopicid(topicId);
topicReply.setContent(replyContent);
if (topicReplyDAO.saveTopicReply(topicReply) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS3);
}
// update forum_topic 'replies', 'lastReplyUserId', 'lastReplyTime'
Date topicLastReplyTime = topicReplyDAO.getTopicReplyById(topicReply.getId()).getCreatetime();
if (topicDAO.updateRepliesAddOneById(topicId) == 0 || topicDAO.updateLastReplyUserIdById(topicId, userId) == 0 || topicDAO.updateLastReplyTimeById(topicId, topicLastReplyTime) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS3);
}
return MapFilterUtil.generateMap(ParamConst.REPLY_ID, topicReply.getId());
}
Aggregations