CommentController.java 1.75 KB
package com.tanpu.community.controller;


import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.qo.CommentQo;
import com.tanpu.community.api.beans.req.theme.CreateCommentReq;
import com.tanpu.community.manager.CommentManager;
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("查看评论")
    @GetMapping(value = "/queryComment")
    @ResponseBody
    public CommonResp<List<CommentQo>> queryComment(@RequestParam String themeId){
        //todo
        String userId = "liujm";
        List<CommentQo> result = commentManager.queryComments(themeId,userId);
        return CommonResp.success(result);
    }

    @ApiOperation("点赞评论")
    @GetMapping(value = "/likeComment")
    @ResponseBody
    public CommonResp<Void> likeComment(@RequestParam String commentId){
        //todo
        String userId = "liujm";
        return CommonResp.success();
    }

    @ApiOperation("举报评论")
    @GetMapping(value = "/reportComment")
    @ResponseBody
    public CommonResp<Void>  reportComment(@RequestParam String commentId){
        //todo
        String userId = "liujm";
        return CommonResp.success();
    }
}