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.WorksCommentPageReq;
import com.ruoyi.controller.req.WorksCommentReq;
import com.ruoyi.controller.resp.WorksCommentPageResp;
import com.ruoyi.controller.resp.WorksCommentResp;
import com.ruoyi.frequency.workscomment.service.WorksCommentService;
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/worksComment")
@Api(tags = "作品评论相关")
public class ApiWorksCommentController extends RyController {

    @Autowired
    private WorksCommentService worksCommentService;

    @PostMapping("/worksComment")
    @UserLoginToken
    @ApiOperation(value = "作品评论", notes = "作品评论")
    public ResponseData<WorksCommentResp> worksComment(@RequestBody WorksCommentReq req) {
        return worksCommentService.worksComment(req, getUserVo());
    }


    @PostMapping("/worksCommentPage")
    @ApiOperation(value = "作品评论列表", notes = "作品评论列表")
    public ResponseData<PageResult<WorksCommentPageResp>> worksCommentPage(@RequestBody WorksCommentPageReq req) {
        return worksCommentService.worksCommentPage(req, getUserVo());
    }


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

    @PostMapping("/worksCommentDetail")
    @ApiOperation(value = "作品评论详情", notes = "作品评论详情")
    public ResponseData<WorksCommentResp> worksCommentDetail(@RequestBody BodyIdReq req) {
        return worksCommentService.worksCommentDetail(req.getId(), getUserVo());
    }


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

}
