package cn.iocoder.yudao.module.mes.dal.mysql.energydevice;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mes.controller.admin.energydevice.vo.EnergyDeviceCheckRecordPageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.energydevice.EnergyDeviceCheckRecordDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 抄表记录 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface EnergyDeviceCheckRecordMapper extends BaseMapperX<EnergyDeviceCheckRecordDO> {

    default PageResult<EnergyDeviceCheckRecordDO> selectPage(EnergyDeviceCheckRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnergyDeviceCheckRecordDO>()
                .eqIfPresent(EnergyDeviceCheckRecordDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(EnergyDeviceCheckRecordDO::getCheckTime, reqVO.getCheckTime())
                .eqIfPresent(EnergyDeviceCheckRecordDO::getDiffValue, reqVO.getDiffValue())
                .eqIfPresent(EnergyDeviceCheckRecordDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(EnergyDeviceCheckRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EnergyDeviceCheckRecordDO::getId));
    }
    default PageResult<EnergyDeviceCheckRecordDO> selectPage(PageParam reqVO, Long deviceId) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnergyDeviceCheckRecordDO>()
                .eq(EnergyDeviceCheckRecordDO::getDeviceId, deviceId)
                .orderByDesc(EnergyDeviceCheckRecordDO::getId));
    }

    default int deleteByDeviceId(Long deviceId) {
        return delete(EnergyDeviceCheckRecordDO::getDeviceId, deviceId);
    }

}