package com.ruoyi.post.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.annotations.UserLoginToken;
import com.ruoyi.common.page.PageResult;
import com.ruoyi.controller.req.DialoguePageReq;
import com.ruoyi.post.controller.req.DeleteCommentReq;
import com.ruoyi.post.controller.req.PostCommentPageReq;
import com.ruoyi.post.controller.req.PostCommentReq;
import com.ruoyi.post.controller.resp.PostCommentPageResp;
import com.ruoyi.post.controller.resp.PostCommentResp;
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
import com.ruoyi.response.ResponseData;
import com.ruoyi.vo.BodyIdReq;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 帖子评论相关
 * @author liwenlong
 *
 */
@CrossOrigin
@RestController
@RequestMapping("/api/postComment")
@Api(tags = "帖子评论相关")
public class ApiPostCommentController extends RyController {

    @Autowired
    private PostCommentService postCommentService;

    @PostMapping("/postComment")
    @UserLoginToken
    @ApiOperation(value = "帖子评论", notes = "帖子评论")
    public ResponseData<PostCommentResp> postComment(@RequestBody PostCommentReq req) {
        return postCommentService.postComment(req,getUserVo());
    }


    @PostMapping("/postCommentPage")
    @ApiOperation(value = "帖子评论列表", notes = "帖子评论列表")
    public ResponseData<PageResult<PostCommentPageResp>> postCommentPage(@RequestBody PostCommentPageReq req) {
        return postCommentService.postCommentPage(req,getUserVo());
    }


    @PostMapping("/deleteComment")
    @UserLoginToken
    @ApiOperation(value = "删除评论", notes = "删除评论")
    public ResponseData deleteComment(@RequestBody DeleteCommentReq req) {
        return postCommentService.deleteComment(req,getUserVo());
    }

    @PostMapping("/postCommentDetail")
    @ApiOperation(value = "帖子评论详情", notes = "帖子评论详情")
    public ResponseData<PostCommentResp> postCommentDetail(@RequestBody BodyIdReq req) {
        return postCommentService.postCommentDetail(req.getId(),getUserVo());
    }

    @PostMapping("/postCommentDialoguePage")
    @ApiOperation(value = "帖子对话评论列表", notes = "帖子对话评论列表")
    public ResponseData<PageResult<Page<PostCommentPageResp>>> postCommentDialoguePage(@RequestBody DialoguePageReq req) {
        return postCommentService.postCommentDialoguePage(req,getUserVo());
    }

}
