use of org.neusoft.neubbs.entity.TopicDO in project neubbs by nuitcoder.
the class TopicDAOTest method testUpdateCategoryById.
/**
* 测试更新话题分类
* - need insert categoryId == 2;
*/
@Test
@Transactional
public void testUpdateCategoryById() {
TopicDO topic = this.saveTestTopicToDB();
int newCategoryId = 2;
Assert.assertEquals(1, topicDAO.updateCategoryById(topic.getId(), newCategoryId));
Assert.assertNotEquals(topic.getCategoryid(), topicDAO.getTopicById(topic.getId()).getCategoryid());
System.out.println("update topicId=" + topic.getId() + " topic categoryid=<" + newCategoryId + "> success!");
}
use of org.neusoft.neubbs.entity.TopicDO in project neubbs by nuitcoder.
the class TopicDAOTest method testRemoveTopicById.
/**
* 测试删除话题
*/
@Test
@Transactional
public void testRemoveTopicById() {
TopicDO topic = this.saveTestTopicToDB();
Assert.assertEquals(1, topicDAO.removeTopicById(topic.getId()));
System.out.println("remove id=" + topic.getId() + " topic");
}
use of org.neusoft.neubbs.entity.TopicDO in project neubbs by nuitcoder.
the class TopicDAOTest method testListTopicByStartRowByCountByUsername.
/**
* 测试(降序,用户 id 分类)获取话题列表
*/
@Test
@Transactional
public void testListTopicByStartRowByCountByUsername() {
this.saveTestTopicToDB();
// first page
int startRow = 0, count = 10;
int userId = 1;
List<TopicDO> listTopic = topicDAO.listTopicDESCByStartRowByCountByUserId(startRow, count, userId);
Assert.assertTrue(listTopic.size() >= 1);
// foreach list
int recordCount = 1;
for (TopicDO topic : listTopic) {
System.out.println("output userid=" + userId + " topic information (No." + (recordCount++) + " recoders): " + topic);
}
}
use of org.neusoft.neubbs.entity.TopicDO in project neubbs by nuitcoder.
the class TopicDAOTest method testSaveTopic.
/**
* 测试保存话题
*/
@Test
@Transactional
public void testSaveTopic() {
TopicDO topic = this.getTestTopicDO();
Assert.assertEquals(1, topicDAO.saveTopic(topic));
Assert.assertTrue(topic.getId() > 0);
Assert.assertNotNull(topicDAO.getTopicById(topic.getId()));
System.out.println("insert topic informatioin : " + topicDAO.getTopicById(topic.getId()));
}
use of org.neusoft.neubbs.entity.TopicDO 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