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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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.ThemeQo;
import com.tanpu.community.api.beans.req.theme.*;
import com.tanpu.community.api.beans.resp.CreateThemeResp;
import com.tanpu.community.api.beans.resp.ThemeListResp;
import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@Slf4j
@RequestMapping(value = "/api/theme")
public class ThemeController {
@Autowired
private ThemeManager themeManager;
@Resource
private UserHolder userHolder;
@AuthLogin
@ApiOperation("发表主题")
@PostMapping(value = "/publish")
@ResponseBody
public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId();
return themeManager.publishTheme(req, userId);
}
@AuthLogin
@ApiOperation("主题列表-推荐/关注/热门/最新")
@PostMapping(value = "/list")
@ResponseBody
public CommonResp<ThemeListResp> selectInterestList(@Validated @RequestBody ThemeListReq req) {
String userId = userHolder.getUserId();
ThemeListResp result = themeManager.queryList(req, userId);
return CommonResp.success(result);
}
@AuthLogin
@ApiOperation("主题正文")
@GetMapping(value = "/detail")
@ResponseBody
public CommonResp<ThemeQo> getDetail(@RequestParam(value = "themeId") String themeId) {
String userId = userHolder.getUserId();
return themeManager.getThemeDetail(themeId, userId);
}
@AuthLogin
@ApiOperation("转发主题")
@PostMapping(value = "/forward")
@ResponseBody
public CommonResp<CreateThemeResp> forwardTheme(@Validated @RequestBody ForwardThemeReq forwardThemeReq) {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.forward(forwardThemeReq, userId));
}
@AuthLogin
@ApiOperation("点赞/取消点赞主题")
@PostMapping(value = "/like")
@ResponseBody
public CommonResp<Void> likeOnTheme(@RequestBody LikeThemeReq req) {
String userId = userHolder.getUserId();
themeManager.like(req, userId);
return CommonResp.success();
}
@AuthLogin
@ApiOperation("用户删除主题")
@GetMapping(value = "/delete")
@ResponseBody
public CommonResp<Void> delete(@RequestParam(value = "themeId") String themeId) {
String userId = userHolder.getUserId();
themeManager.delete(themeId, userId);
return CommonResp.success();
}
@AuthLogin
@ApiOperation("收藏/取消收藏主题")
@PostMapping(value = "/collect")
@ResponseBody
public CommonResp<Void> bookTheme(@RequestBody CollectThemeReq req) {
String userId = userHolder.getUserId();
themeManager.collect(req, userId);
return CommonResp.success();
}
@AuthLogin
@ApiOperation("举报主题")
@PostMapping(value = "/report")
@ResponseBody
public CommonResp<Void> complaintTheme(@RequestBody ReportThemeReq req) {
String userId = userHolder.getUserId();
themeManager.report(req, userId);
return CommonResp.success();
}
@AuthLogin
@ApiOperation("关注主题更新数量")
@GetMapping(value = "/updateCount")
@ResponseBody
public CommonResp<Integer> updateCount() {
String userId = userHolder.getUserId();
return CommonResp.success(themeManager.getFollowUpdateCount(userId));
}
@ApiOperation("专栏同步主题")
@PostMapping(value = "/convertFromNewsFeed")
@ResponseBody
public CommonResp<Void> convertFromNewsFeed(@Validated @RequestBody SynchroThemeReq req) {
themeManager.convertFromNewsFeed(req);
return CommonResp.success();
}
}