package com.ycwl.basic.service.pc.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.VideoMapper;
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.stereotype.Service;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/12/3 16:31
 */
@Service
public class VideoServiceImpl implements VideoService {

    @Autowired
    private VideoMapper videoMapper;

    @Override
    public ApiResponse<PageInfo<VideoRespVO>> pageQuery(VideoReqQuery videoReqQuery) {
        PageHelper.startPage(videoReqQuery.getPageNum(), videoReqQuery.getPageSize());
        List<VideoRespVO> list = videoMapper.list(videoReqQuery);
        PageInfo<VideoRespVO> pageInfo = new PageInfo<>(list);
        return ApiResponse.success(pageInfo);
    }

    @Override
    public ApiResponse<List<VideoRespVO>> list(VideoReqQuery videoReqQuery) {
        return ApiResponse.success(videoMapper.list(videoReqQuery));
    }

    @Override
    public ApiResponse<VideoRespVO> getById(Long id) {
        return ApiResponse.success(videoMapper.getById(id));
    }

}
