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
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.CommentQo;
import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
import com.tanpu.community.api.beans.req.page.Page;
import com.tanpu.community.manager.CommentManager;
import com.tanpu.community.util.PageUtils;
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;
import java.util.List;
@RestController
@Slf4j
@RequestMapping(value = "/api/theme")
public class CommentController {
@Autowired
private CommentManager commentManager;
@Resource
private UserHolder userHolder;
@ApiOperation("发表评论")
@AuthLogin
@PostMapping(value = "/publishComment")
@ResponseBody
public CommonResp<Void> publishCommet(@Validated @RequestBody CreateCommentReq req) {
String userId = userHolder.getUserId();
commentManager.comment(req, userId);
return CommonResp.success();
}
@ApiOperation("评论列表")
@AuthLogin
@PostMapping(value = "/queryComment")
@ResponseBody
public CommonResp<Page<CommentQo>> queryComment(@Validated @RequestBody QueryCommentReq req) {
String userId = userHolder.getUserId();
List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
return CommonResp.success(PageUtils.page(req.getPage(), result));
}
@ApiOperation("点赞评论")
@PostMapping(value = "/likeComment")
@AuthLogin
@ResponseBody
public CommonResp<Void> likeComment(@Validated @RequestBody LikeCommentReq req) {
String userId = userHolder.getUserId();
commentManager.likeComment(req, userId);
return CommonResp.success();
}
@ApiOperation("举报评论")
@GetMapping(value = "/reportComment")
@AuthLogin
@ResponseBody
public CommonResp<Void> reportComment(@RequestParam String commentId) {
//todo
String userId = userHolder.getUserId();
return CommonResp.failed("功能暂未开放");
}
}