package cn.iocoder.yudao.module.pms.dal.mysql.iotdevicestatuslog;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicestatuslog.vo.IotDeviceStatusLogPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdevicestatuslog.IotDeviceStatusLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 设备状态调整日志 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotDeviceStatusLogMapper extends BaseMapperX<IotDeviceStatusLogDO> {

    default PageResult<IotDeviceStatusLogDO> selectPage(IotDeviceStatusLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceStatusLogDO>()
                .eqIfPresent(IotDeviceStatusLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDeviceStatusLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDeviceStatusLogDO::getOldStatus, reqVO.getOldStatus())
                .eqIfPresent(IotDeviceStatusLogDO::getNewStatus, reqVO.getNewStatus())
                .eqIfPresent(IotDeviceStatusLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDeviceStatusLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDeviceStatusLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceStatusLogDO::getId));
    }

    default List<IotDeviceStatusLogDO> selectList(IotDeviceStatusLogPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotDeviceStatusLogDO>()
                .eqIfPresent(IotDeviceStatusLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDeviceStatusLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDeviceStatusLogDO::getOldStatus, reqVO.getOldStatus())
                .eqIfPresent(IotDeviceStatusLogDO::getNewStatus, reqVO.getNewStatus())
                .eqIfPresent(IotDeviceStatusLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDeviceStatusLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDeviceStatusLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceStatusLogDO::getId));
    }

}