package com.xueyi.system.emcs.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.xueyi.common.web.entity.manager.impl.BaseManagerImpl;
import com.xueyi.system.emcs.domain.dto.DmExceptionLogDto;
import com.xueyi.system.emcs.domain.model.DmExceptionLogConverter;
import com.xueyi.system.emcs.domain.po.DmExceptionLogPo;
import com.xueyi.system.emcs.domain.query.DmExceptionLogQuery;
import com.xueyi.system.emcs.manager.IDmExceptionLogManager;
import com.xueyi.system.emcs.mapper.DmExceptionLogMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 数字人状态事件上报日志管理 数据封装层处理
 *
 * @author xueyi
 */
@Component
public class DmExceptionLogManager extends BaseManagerImpl<DmExceptionLogQuery, DmExceptionLogDto, DmExceptionLogPo, DmExceptionLogMapper, DmExceptionLogConverter> implements IDmExceptionLogManager {
    @Override
    public List<DmExceptionLogDto> selectListRangeByCreateTime(String start,String end) {
        return mapperDto(super.baseMapper.selectList(new LambdaQueryWrapper<DmExceptionLogPo>()
                .and(StringUtils.isNotEmpty(start) && StringUtils.isNotEmpty(end), t->{
                    t.ge(DmExceptionLogPo::getCreateTime,start);
                    t.le(DmExceptionLogPo::getCreateTime,end);
                })));
    }

    @Override
    public List<DmExceptionLogDto> selectListRangeByCreateTimeAndDevId(String start, String end, String devId) {
        return mapperDto(super.baseMapper.selectList(new LambdaQueryWrapper<DmExceptionLogPo>().eq(DmExceptionLogPo::getDevId,devId)
                .and(StringUtils.isNotEmpty(start) && StringUtils.isNotEmpty(end), t->{
                    t.ge(DmExceptionLogPo::getCreateTime,start);
                    t.le(DmExceptionLogPo::getCreateTime,end);
                })));
    }


}