package com.ruoyi.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.CommentPageReq;
import com.ruoyi.controller.req.CommentReq;
import com.ruoyi.controller.req.DialoguePageReq;
import com.ruoyi.controller.resp.CommentPageResp;
import com.ruoyi.controller.resp.CommentResp;
import com.ruoyi.frequency.comment.service.CommentService;
import com.ruoyi.post.controller.req.DeleteCommentReq;
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/comment")
@Api(tags = "新闻评论相关")
public class ApiCommentController extends RyController {

    @Autowired
    private CommentService commentService;

    @PostMapping("/comment")
    @UserLoginToken
    @ApiOperation(value = "评论", notes = "评论")
    public ResponseData<CommentResp> comment(@RequestBody CommentReq req) {
        return commentService.comment(req,getUserVo());
    }


    @PostMapping("/commentPage")
    @ApiOperation(value = "评论列表", notes = "评论列表")
    public ResponseData<PageResult<Page<CommentPageResp>>> commentPage(@RequestBody CommentPageReq req) {
        return commentService.commentPage(req,getUserVo());
    }


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

    @PostMapping("/commentDetail")
    @ApiOperation(value = "新闻评论详情", notes = "新闻评论详情")
    public ResponseData<CommentResp> commentDetail(@RequestBody BodyIdReq req) {
        return commentService.commentDetail(req.getId(),getUserVo());
    }


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

}
