use of org.neusoft.neubbs.entity.TopicDO in project neubbs by nuitcoder.
the class TopicServiceImpl method listTopics.
@Override
public List<Map<String, Object>> listTopics(int limit, int page, String categoryNick, String username) {
// if limit = 0, explain no input limit, use neubbs.properties default param
if (limit == 0) {
limit = neubbsConfig.getTopicsApiRequestParamLimitDefault();
}
this.confirmNoExceedTopicTotalNumber(limit, page);
int categoryId = categoryNick == null ? 0 : this.getTopicCategoryNotNullByNick(categoryNick).getId();
int userId = username == null ? 0 : this.getUserNotNullByName(username).getId();
// get database query results
List<TopicDO> dbQueryTopicList = this.getTopicList(limit, page, categoryId, userId);
if (dbQueryTopicList.size() == 0) {
throw new ServiceException(ApiMessage.NO_QUERY_TOPICS).log(LogWarnEnum.TS16);
}
List<Map<String, Object>> resultTopicList = new ArrayList<>(dbQueryTopicList.size());
for (TopicDO topic : dbQueryTopicList) {
Map<String, Object> topicInfoMap = this.getTopicInfoMap(topic);
Map<String, Object> topicContentInfoMap = this.getTopicContentInfoMap(this.getTopicContent(topic.getId()));
Map<String, Object> topicCategoryInfoMap = this.getTopicCategoryInfoMap(this.getTopicCategory(topic.getCategoryid()));
Map<String, Object> authorUserMap = this.getTopicUserInfoMap(this.getUser(topic.getUserid()));
Map<String, Object> lastReplyUserMap = this.getTopicUserInfoMap(this.getUser(topic.getLastreplyuserid()));
// merge all information map
topicInfoMap.putAll(topicContentInfoMap);
topicInfoMap.put(ParamConst.CATEGORY, topicCategoryInfoMap);
topicInfoMap.put(ParamConst.USER, authorUserMap);
topicInfoMap.put(ParamConst.LAST_REPLY_USER, lastReplyUserMap);
resultTopicList.add(topicInfoMap);
}
return resultTopicList;
}
use of org.neusoft.neubbs.entity.TopicDO 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.TopicDO in project neubbs by nuitcoder.
the class TopicServiceImpl method listHotTopics.
@Override
public List<Map<String, Object>> listHotTopics() {
List<TopicDO> topicList = topicDAO.listTopicOrderByCreatetimeDESCByRepliesDESCLimitTen();
List<Map<String, Object>> hotTopicMapList = new ArrayList<>(topicList.size());
for (TopicDO topic : topicList) {
Map<String, Object> itemTopicMap = this.getTopicInfoMap(topic);
itemTopicMap.put(ParamConst.CATEGORY, this.getTopicCategoryInfoMap(this.getTopicCategory(topic.getCategoryid())));
itemTopicMap.put(ParamConst.USER, this.getTopicUserInfoMap(this.getUser(topic.getUserid())));
itemTopicMap.put(ParamConst.LAST_REPLY_USER, this.getTopicUserInfoMap(this.getUser(topic.getLastreplyuserid())));
// add to list
hotTopicMapList.add(itemTopicMap);
}
return hotTopicMapList;
}
Aggregations