CommentController.java 2.07 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3 4 5
package com.tanpu.community.controller;


import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.qo.CommentQo;
刘基明's avatar
刘基明 committed
6
import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
刘基明's avatar
刘基明 committed
7
import com.tanpu.community.api.beans.req.comment.LikeCommentReq;
刘基明's avatar
刘基明 committed
8 9
import com.tanpu.community.api.beans.req.comment.QueryCommentReq;
import com.tanpu.community.api.beans.req.page.Page;
刘基明's avatar
刘基明 committed
10
import com.tanpu.community.manager.CommentManager;
刘基明's avatar
刘基明 committed
11
import com.tanpu.community.util.PageUtils;
刘基明's avatar
刘基明 committed
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
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping(value = "/api/theme")
public class CommentController {

    @Autowired
    private CommentManager commentManager;

    @ApiOperation("发表评论")
    @PostMapping(value = "/publishComment")
    @ResponseBody
    public CommonResp<Void> publishCommet(@RequestBody CreateCommentReq req) {
        String userId = "liujm";
        commentManager.comment(req, userId);
        return CommonResp.success();
    }

    @ApiOperation("查看评论")
刘基明's avatar
刘基明 committed
37
    @PostMapping(value = "/queryComment")
刘基明's avatar
刘基明 committed
38
    @ResponseBody
刘基明's avatar
刘基明 committed
39
    public CommonResp<Page<CommentQo>> queryComment(@RequestBody QueryCommentReq req) {
刘基明's avatar
刘基明 committed
40 41
        //todo
        String userId = "liujm";
刘基明's avatar
刘基明 committed
42
        List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId);
刘基明's avatar
刘基明 committed
43
        return CommonResp.success(PageUtils.page(req.getPage(), result));
刘基明's avatar
刘基明 committed
44 45 46
    }

    @ApiOperation("点赞评论")
刘基明's avatar
刘基明 committed
47
    @PostMapping(value = "/likeComment")
刘基明's avatar
刘基明 committed
48
    @ResponseBody
刘基明's avatar
刘基明 committed
49
    public CommonResp<Void> likeComment(@RequestBody LikeCommentReq req) {
刘基明's avatar
刘基明 committed
50
        String userId = "liujm";
刘基明's avatar
刘基明 committed
51
        commentManager.likeComment(req, userId);
刘基明's avatar
刘基明 committed
52 53 54 55
        return CommonResp.success();
    }

    @ApiOperation("举报评论")
刘基明's avatar
刘基明 committed
56
    @GetMapping(value = "/reportComment")
刘基明's avatar
刘基明 committed
57
    @ResponseBody
刘基明's avatar
刘基明 committed
58
    public CommonResp<Void> reportComment(@RequestParam String commentId) {
刘基明's avatar
刘基明 committed
59 60
        //todo
        String userId = "liujm";
刘基明's avatar
刘基明 committed
61
        return CommonResp.failed("功能暂未开放");
刘基明's avatar
刘基明 committed
62 63
    }
}