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.DialoguePageReq;
import com.ruoyi.controller.req.VoteCommentPageReq;
import com.ruoyi.controller.req.VoteCommentReq;
import com.ruoyi.controller.resp.VoteCommentPageResp;
import com.ruoyi.controller.resp.VoteCommentResp;
import com.ruoyi.frequency.votecomment.service.VoteCommentService;
import com.ruoyi.frequency.votecomment.service.VoteCommentService;
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/voteComment")
@Api(tags = "投票评论相关")
public class ApiVoteCommentController extends RyController {

    @Autowired
    private VoteCommentService voteCommentService;

    @PostMapping("/voteComment")
    @UserLoginToken
    @ApiOperation(value = "投票评论", notes = "投票评论")
    public ResponseData<VoteCommentResp> voteComment(@RequestBody VoteCommentReq req) {
        return voteCommentService.voteComment(req, getUserVo());
    }


    @PostMapping("/voteCommentPage")
    @ApiOperation(value = "投票评论列表", notes = "投票评论列表")
    public ResponseData<PageResult<VoteCommentPageResp>> voteCommentPage(@RequestBody VoteCommentPageReq req) {
        return voteCommentService.voteCommentPage(req, getUserVo());
    }


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

    @PostMapping("/voteCommentDetail")
    @ApiOperation(value = "投票评论详情", notes = "投票评论详情")
    public ResponseData<VoteCommentResp> voteCommentDetail(@RequestBody BodyIdReq req) {
        return voteCommentService.voteCommentDetail(req.getId(), getUserVo());
    }


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

}
