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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.AuthLogin;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.community.api.beans.qo.DiscussionAeraQo;
import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.qo.TopicPageDetailQo;
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.FollowTopicReq;
import com.tanpu.community.api.beans.req.topic.TopicDiscussionReq;
import com.tanpu.community.api.beans.req.topic.TopicSearchReq;
import com.tanpu.community.manager.TopicManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@Slf4j
@RequestMapping(value = "/api/topic")
@ResponseBody
public class TopicController {
@Resource
private TopicManager topicManager;
@Resource
private UserHolder userHolder;
@AuthLogin
@GetMapping(value = "/followList")
@ApiOperation("关注话题列表")
public CommonResp<List<TopicFollowQo>> getFollowList(@RequestParam(required = false,value = "keyword") String keyword) {
return CommonResp.success(topicManager.getFollowTopicList(keyword));
}
@PostMapping(value = "/list")
@ApiOperation("热门话题,含搜索")
public CommonResp<Page<TopicRankQo>> getTopicList(@RequestBody TopicSearchReq req) {
return CommonResp.success(topicManager.getAllTopicRankInfo(req));
}
@GetMapping(value = "/detailPage")
@ApiOperation("话题详情页")
public CommonResp<TopicPageDetailQo> getDetail(@RequestParam String topicId) {
return topicManager.getDetail(topicId);
}
@GetMapping(value = "/titleList")
@ApiOperation("首页顶部话题标题列")
public CommonResp<List<TopicRankQo>> getTop4Topic() {
return CommonResp.success(topicManager.getTop4TopicTitles());
}
@AuthLogin
@PostMapping(value = "/follow")
@ApiOperation("关注话题(讨论区),动作")
public CommonResp<Void> follow(@RequestBody FollowTopicReq req) {
topicManager.followTopic(req, userHolder.getUserId());
return CommonResp.success();
}
@PostMapping(value = "/rel/discussion")
@ApiOperation("资源关联讨论区,课程(基金)介绍用")
public CommonResp<DiscussionAeraQo> getForum(@RequestBody TopicDiscussionReq req) {
return CommonResp.success(topicManager.getForum(req));
}
}