package com.ycwl.basic.controller.pc;

import com.github.pagehelper.PageInfo;
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
import com.ycwl.basic.service.pc.VideoService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/12/3 16:28
 */

@RestController
@RequestMapping("/api/video/v1")
// 视频成片管理
public class VideoController {

    @Autowired
    private VideoService videoService;

    // 分页查询成片
    @PostMapping("/page")
    public ApiResponse<PageInfo<VideoRespVO>> pageQuery(@RequestBody VideoReqQuery videoReqQuery) {
        return videoService.pageQuery(videoReqQuery);
    }
    // 查询成片列表
    @PostMapping("/list")
    public ApiResponse<List<VideoRespVO>> list(@RequestBody VideoReqQuery videoReqQuery) {
        return videoService.list(videoReqQuery);
    }
    // 查询成片详情
    @GetMapping("/getDetail/{id}")
    public ApiResponse<VideoRespVO> getById(@PathVariable Long id) {
        return videoService.getById(id);
    }

    /**
     * 查询视频是否被购买
     *
     * @param videoId 视频ID
     * @return 是否已购买
     */
    @GetMapping("/checkBuyStatus")
    public ApiResponse<Boolean> checkBuyStatus(@RequestParam("videoId") Long videoId) {
        Boolean isBuy = videoService.checkVideoBuyStatus(videoId);
        return ApiResponse.success(isBuy);
    }

}
