package org.jeecg.modules.bytedance.advertise.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo;
import org.jeecg.modules.bytedance.advertise.mapper.ByteDanceVideoInfoMapper;
import org.jeecg.modules.bytedance.advertise.service.IByteDanceVideoInfoService;
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
@Primary
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);
    }

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

    @Override
    public List<ByteDanceVideoInfo> listByParams(Long accountId, String startTime, String endTime, Long videoCnt,long creativeCnt) {
        return videoInfoMapper.getNewVideoByParams(accountId,startTime,endTime,videoCnt,creativeCnt);
    }

    @Override
    public List<ByteDanceVideoInfo> topMatByParams(Long projectId, Long accountId, String startTime, String endTime, Long videoCnt) {
        return videoInfoMapper.topMatByParams(projectId,accountId,startTime,endTime,videoCnt);
    }
}
