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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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.feign.community.FeignClientForCommunity;
import com.tanpu.community.manager.ThemeManager;
import com.tanpu.community.service.TraceTestService;
import com.tanpu.community.util.HttpServletHelper;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
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;
@Resource
private HttpServletHelper httpServletHelper;
@Autowired
private TraceTestService traceTestService;
@AuthLogin
@ApiOperation("发表主题")
@PostMapping(value = "/publish")
@ResponseBody
public CommonResp<CreateThemeResp> publishTheme(@Validated @RequestBody CreateThemeReq req) {
String userId = userHolder.getUserId();
return themeManager.publishTheme(req, userId);
}
@ApiOperation("主题列表-推荐/关注/热门/最新")
@PostMapping(value = "/list")
@ResponseBody
public CommonResp<ThemeListResp> selectInterestList(@Validated @RequestBody ThemeListReq req) {
String selfUserId = httpServletHelper.getCurrentUserId();
if (StringUtils.isEmpty(req.getUserId())) {
req.setUserId(selfUserId);
}
ThemeListResp result = themeManager.queryList(req, req.getUserId());
return CommonResp.success(result);
}
@ApiOperation("主题正文")
@GetMapping(value = "/detail")
@ResponseBody
public CommonResp<ThemeQo> getDetail(@RequestParam(value = "themeId") String themeId,
@RequestParam(value = "userId", required = false) String userId) {
String selfUserId = httpServletHelper.getCurrentUserId();
if (StringUtils.isEmpty(userId)) {
userId = selfUserId;
}
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();
}
@ApiOperation("文本查重初始化")
@GetMapping(value = "/initTextCheck")
@ResponseBody
public CommonResp<Void> initTextCheck() {
themeManager.initThemeTextCheck();
return CommonResp.success();
}
@PostMapping(value = "/testTrace")
@ResponseBody
public CommonResp<Void> testTrace() {
traceTestService.testTraceId();
return CommonResp.success();
}
}