package com.fs.live.service.impl;

import java.util.Collections;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.common.utils.DateUtils;
import com.fs.live.domain.LiveAnchor;
import com.fs.live.mapper.LiveAnchorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.live.mapper.LiveVideoMapper;
import com.fs.live.domain.LiveVideo;
import com.fs.live.service.ILiveVideoService;

/**
 * 直播视频Service业务层处理
 * 
 * @author fs
 * @date 2025-01-17
 */
@Service
public class LiveVideoServiceImpl extends ServiceImpl<LiveVideoMapper, LiveVideo> implements ILiveVideoService
{
    @Autowired
    private LiveVideoMapper liveVideoMapper;

    /**
     * 查询直播视频
     * 
     * @param videoId 直播视频主键
     * @return 直播视频
     */
    @Override
    public LiveVideo selectLiveVideoByVideoId(Long videoId)
    {
        return liveVideoMapper.selectLiveVideoByVideoId(videoId);
    }

    /**
     * 查询直播视频列表
     * 
     * @param liveVideo 直播视频
     * @return 直播视频
     */
    @Override
    public List<LiveVideo> selectLiveVideoList(LiveVideo liveVideo)
    {
        return liveVideoMapper.selectLiveVideoList(liveVideo);
    }

    /**
     * 新增直播视频
     * 
     * @param liveVideo 直播视频
     * @return 结果
     */
    @Override
    public int insertLiveVideo(LiveVideo liveVideo)
    {
        liveVideo.setCreateTime(DateUtils.getNowDate());
        return liveVideoMapper.insertLiveVideo(liveVideo);
    }

    /**
     * 修改直播视频
     * 
     * @param liveVideo 直播视频
     * @return 结果
     */
    @Override
    public int updateLiveVideo(LiveVideo liveVideo)
    {
        liveVideo.setUpdateTime(DateUtils.getNowDate());
        return liveVideoMapper.updateLiveVideo(liveVideo);
    }

    /**
     * 批量删除直播视频
     * 
     * @param videoIds 需要删除的直播视频主键
     * @return 结果
     */
    @Override
    public int deleteLiveVideoByVideoIds(Long[] videoIds)
    {
        return liveVideoMapper.deleteLiveVideoByVideoIds(videoIds);
    }

    /**
     * 删除直播视频信息
     * 
     * @param videoId 直播视频主键
     * @return 结果
     */
    @Override
    public int deleteLiveVideoByVideoId(Long videoId)
    {
        return liveVideoMapper.deleteLiveVideoByVideoId(videoId);
    }

    @Override
    public List<LiveVideo> listByLiveId(Long liveId, Integer type) {
        return list(new QueryWrapper<LiveVideo>().eq("live_id", liveId).eq("video_type", type));
    }
}
