use of org.neusoft.neubbs.entity.TopicActionDO in project neubbs by nuitcoder.
the class TopicActionDAOTest method saveTestTopicActionDOToDatabase.
/**
* 保存测试 TopicActionDO 对象至数据库
* - 新建测试话题
* - 保存,且重新查询数据库获得对象(根据话题 id,进行查询)
*
* @return TopicActionDO 话题行为对象
*/
private TopicActionDO saveTestTopicActionDOToDatabase() {
TopicDO topic = new TopicDO();
topic.setUserid(1);
topic.setCategoryid(1);
topic.setTitle("test title");
Assert.assertEquals(1, topicDAO.saveTopic(topic));
TopicActionDO topicAction = new TopicActionDO();
topicAction.setTopicId(topic.getId());
Assert.assertEquals(1, topicActionDAO.saveTopicAction(topicAction));
return topicActionDAO.getTopicAction(topic.getId());
}
use of org.neusoft.neubbs.entity.TopicActionDO in project neubbs by nuitcoder.
the class TopicServiceImpl method saveTopic.
@Override
public Map<String, Object> saveTopic(int userId, String categoryNick, String title, String topicContent) {
// judge whether exist category(nick)
TopicCategoryDO category = this.getTopicCategoryNotNullByNick(categoryNick);
// build TopicDO, TopicContentDO, TopicActionDO
TopicDO topic = new TopicDO();
topic.setUserid(userId);
topic.setCategoryid(category.getId());
topic.setTitle(title);
// insert forum_topic, get new topic id
if (topicDAO.saveTopic(topic) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS1);
}
// insert forum_topic_content
TopicContentDO topicContentDO = new TopicContentDO();
topicContentDO.setTopicid(topic.getId());
topicContentDO.setContent(topicContent);
if (topicContentDAO.saveTopicContent(topicContentDO) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS2);
}
// insert forum_topic_action
TopicActionDO topicAction = new TopicActionDO();
topicAction.setTopicId(topic.getId());
if (topicActionDAO.saveTopicAction(topicAction) == 0) {
throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS24);
}
return MapFilterUtil.generateMap(ParamConst.TOPIC_ID, topic.getId());
}
Aggregations