Search in sources :

Example 1 with TopicCategoryDO

use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.

the class TopicServiceImpl method alterTopicContent.

@Override
public void alterTopicContent(int topicId, String newCategoryNick, String newTitle, String newTopicContent) {
    this.getTopicNotNull(topicId);
    this.getTopicContentNotNull(topicId);
    TopicCategoryDO category = this.getTopicCategoryNotNullByNick(newCategoryNick);
    // update forum_topic 'fucg_id', 'ft_title'
    if (topicDAO.updateCategoryById(topicId, category.getId()) == 0 || topicDAO.updateTitleById(topicId, newTitle) == 0) {
        throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS7);
    }
    // update forum_topic_content 'ftc_content'
    if (topicContentDAO.updateContentByTopicId(topicId, newTopicContent) == 0) {
        throw new ServiceException(ApiMessage.DATABASE_EXCEPTION).log(LogWarnEnum.TS8);
    }
}
Also used : ServiceException(org.neusoft.neubbs.exception.ServiceException) TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO)

Example 2 with TopicCategoryDO

use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.

the class TopicCategoryDAOTest method testListAllTopicCategory.

/**
 * 测试获取所有话题分类
 */
@Test
@Transactional
public void testListAllTopicCategory() {
    this.savaTestTopicCategoryDOToDatabase();
    List<TopicCategoryDO> categoryList = topicCategoryDAO.listAllTopicCategory();
    Assert.assertTrue(categoryList.size() >= 1);
    int categoryCount = 1;
    for (TopicCategoryDO topicCategory : categoryList) {
        System.out.println("output topic category information ( No." + (categoryCount++) + " records):" + JsonUtil.toJsonString(topicCategory));
    }
    System.out.println("get all category list success!");
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 3 with TopicCategoryDO

use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.

the class TopicCategoryDAOTest method savaTestTopicCategoryDOToDatabase.

/**
 * 保存话题分类至数据库
 *
 * @return TopicContent 数据库保存后,重新查询的话题分类
 */
private TopicCategoryDO savaTestTopicCategoryDOToDatabase() {
    // build TopicCategoryDO, sava database
    TopicCategoryDO category = new TopicCategoryDO();
    category.setNick("testCategory");
    category.setName("测试分类");
    Assert.assertEquals(1, topicCategoryDAO.saveTopicCategory(category));
    return topicCategoryDAO.getTopicCategoryById(category.getId());
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO)

Example 4 with TopicCategoryDO

use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.

the class TopicCategoryDAOTest method testUpdateDescriptionByNick.

/**
 * 测试修改话题分类描述
 */
@Test
@Transactional
public void testUpdateDescriptionByNick() {
    TopicCategoryDO category = this.savaTestTopicCategoryDOToDatabase();
    String newDescription = "this is new category description";
    Assert.assertEquals(1, topicCategoryDAO.updateDescriptionByNick(category.getNick(), newDescription));
    Assert.assertEquals(newDescription, topicCategoryDAO.getTopicCategoryById(category.getId()).getDescription());
    System.out.println("update categoryNick=" + category.getNick() + " category description=<" + newDescription + ">");
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Example 5 with TopicCategoryDO

use of org.neusoft.neubbs.entity.TopicCategoryDO in project neubbs by nuitcoder.

the class TopicCategoryDAOTest method testSaveTopicCategory.

/**
 * 测试保存保存话题分类
 */
@Test
@Transactional
public void testSaveTopicCategory() {
    TopicCategoryDO category = this.savaTestTopicCategoryDOToDatabase();
    System.out.println("insert topic category information: " + category);
}
Also used : TopicCategoryDO(org.neusoft.neubbs.entity.TopicCategoryDO) Test(org.junit.Test) Transactional(javax.transaction.Transactional)

Aggregations

TopicCategoryDO (org.neusoft.neubbs.entity.TopicCategoryDO)15 Test (org.junit.Test)9 Transactional (javax.transaction.Transactional)8 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)3 TopicDO (org.neusoft.neubbs.entity.TopicDO)3 ServiceException (org.neusoft.neubbs.exception.ServiceException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 TopicActionDO (org.neusoft.neubbs.entity.TopicActionDO)1 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)1 UserDO (org.neusoft.neubbs.entity.UserDO)1