package cn.iocoder.yudao.module.iot.dal.mysql.deviceoperationrecord;

import java.util.*;

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.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 运行记录 Mapper
 *
 * @author 必硕科技
 */
@Mapper
public interface DeviceOperationRecordMapper extends BaseMapperX<DeviceOperationRecordDO> {

    default PageResult<DeviceOperationRecordDO> selectPage(DeviceOperationRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceOperationRecordDO>()
                .eqIfPresent(DeviceOperationRecordDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DeviceOperationRecordDO::getModelId, reqVO.getModelId())
                .eqIfPresent(DeviceOperationRecordDO::getRule, reqVO.getRule())
                .eqIfPresent(DeviceOperationRecordDO::getAddressValue, reqVO.getAddressValue())
                .betweenIfPresent(DeviceOperationRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DeviceOperationRecordDO::getRecordType, reqVO.getRecordType())
                .orderByDesc(DeviceOperationRecordDO::getId));
    }

    IPage<DeviceTotalTimeRecordRespVO> deviceOperationPage(Page<DeviceTotalTimeRecordRespVO> page,@Param("pageReqVO") DeviceTotalTimeRecordReqVO pageReqVO);

}