package cn.com.ctop.toutiao.modules.material.service.impl;

import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
import cn.com.ctop.toutiao.modules.material.mapper.ByteDanceVideoInfoMapper;
import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 今日头条视频素材信息
 * @Author: jeecg-boot
 * @Date: 2019-07-29
 * @Version: V1.0
 */
@Service
public class ByteDanceVideoInfoServiceImpl extends ServiceImpl<ByteDanceVideoInfoMapper, ByteDanceVideoInfo> implements IByteDanceVideoInfoService {
    @Resource
    private ByteDanceVideoInfoMapper videoInfoMapper;

    @Override
    public void replaceBatch(List<ByteDanceVideoInfo> videoInfoList) {
        videoInfoMapper.replaceBatch(videoInfoList);
    }

    @Override
    public ByteDanceVideoInfo getOneByParams(Long materialId) {
        QueryWrapper<ByteDanceVideoInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("material_id",materialId);
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
