package com.xxl.job.executor.material.service.impl;

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

import java.util.List;

/**
 * @Description: 今日头条视频素材信息
 * @Author: jeecg-boot
 * @Date: 2019-07-29
 * @Version: V1.0
 */
@Service
@Primary
public class ByteDanceVideoInfoServiceImpl extends ServiceImpl<ByteDanceVideoInfoMapper, ByteDanceVideoInfo> implements IByteDanceVideoInfoService {
    @Autowired
    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);
    }

    @Override
    public void updateMaterialType() {
        videoInfoMapper.updateVideoVerticalType();
        videoInfoMapper.updateVideoHorizonType();
    }
}
