1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.tanpu.community.manager;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.community.api.beans.qo.TopicRankQo;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.service.RankService;
import com.tanpu.community.service.TopicService;
import com.tanpu.community.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TopicManager {
@Autowired
private TopicService topicService;
@Autowired
private RankService rankService;
// 首页-话题标签
public List<TopicRankQo> getTop4TopicTitles() {
return rankService.getRankTopicListTop4();
}
// 话题搜索列表
public Page<TopicRankQo> getAllTopicBriefInfo(TopicSearchReq req) {
List<TopicRankQo> topicList = rankService.getRankTopicList(req.getSearchKeyword());
return PageUtils.page(req.getPage(), topicList);
}
// 话题详情页
public CommonResp<TopicRankQo> getDetail(String topicId) {
TopicEntity topicEntity = topicService.queryById(topicId);
if (topicEntity==null){
return CommonResp.error(ErrorCodeConstant.TOPIC_NOT_FOUND.getCode(), "抱歉!该话题已下线。");
}
return CommonResp.success(rankService.getTopicDetail(topicId));
}
}