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

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.iotdeviceallotlog.vo.IotDeviceAllotLogPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdeviceallotlog.IotDeviceAllotLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 设备调拨日志 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotDeviceAllotLogMapper extends BaseMapperX<IotDeviceAllotLogDO> {

    default PageResult<IotDeviceAllotLogDO> selectPage(IotDeviceAllotLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceAllotLogDO>()
                .eqIfPresent(IotDeviceAllotLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDeviceAllotLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDeviceAllotLogDO::getOldDeptId, reqVO.getOldDeptId())
                .eqIfPresent(IotDeviceAllotLogDO::getNewDeptId, reqVO.getNewDeptId())
                .eqIfPresent(IotDeviceAllotLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDeviceAllotLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDeviceAllotLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceAllotLogDO::getId));
    }

    default List<IotDeviceAllotLogDO> selectList(IotDeviceAllotLogPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotDeviceAllotLogDO>()
                .eqIfPresent(IotDeviceAllotLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDeviceAllotLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDeviceAllotLogDO::getOldDeptId, reqVO.getOldDeptId())
                .eqIfPresent(IotDeviceAllotLogDO::getNewDeptId, reqVO.getNewDeptId())
                .eqIfPresent(IotDeviceAllotLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDeviceAllotLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDeviceAllotLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceAllotLogDO::getDeviceId));
    }

}