package com.ltgk.video.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ltgk.video.domain.entity.DsVideoLog;
import com.ltgk.video.domain.vo.GetVideoStatusLogVo;
import com.ltgk.video.mapper.DsVideoLogMapper;
import com.ltgk.video.service.DsVideoLogService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.github.pagehelper.page.PageMethod.startPage;

@Service
public class DsVideoLogServiceImpl  extends ServiceImpl<DsVideoLogMapper, DsVideoLog> implements DsVideoLogService{


    @Override
    public List<DsVideoLog> getVideoStatusLog(GetVideoStatusLogVo req) {
        startPage(req.getPageNum(), req.getPageSize());
        LambdaQueryWrapper<DsVideoLog> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(req.getVideoId()),DsVideoLog::getVideoId, req.getVideoId());
        lqw.eq(StringUtils.isNotBlank(req.getRunStatus()),DsVideoLog::getRunStatus, req.getRunStatus());
        lqw.eq(StringUtils.isNotBlank(req.getVideoCode()),DsVideoLog::getVideoCode, req.getVideoCode());
        lqw.eq(StringUtils.isNotBlank(req.getVideoName()),DsVideoLog::getVideoName, req.getVideoName());
        lqw.gt(ObjectUtils.isNotEmpty(req.getStartTime()),DsVideoLog::getCreateAt, req.getStartTime());
        lqw.lt(ObjectUtils.isNotEmpty(req.getEndTime()),DsVideoLog::getCreateAt, req.getEndTime());
        lqw.orderByDesc(DsVideoLog::getCreateAt);
        return this.list(lqw);
    }
}
