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

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

import java.util.List;

/**
 * 设备责任人日志 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotDevicePersonLogMapper extends BaseMapperX<IotDevicePersonLogDO> {

    default PageResult<IotDevicePersonLogDO> selectPage(IotDevicePersonLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDevicePersonLogDO>()
                .eqIfPresent(IotDevicePersonLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDevicePersonLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDevicePersonLogDO::getOldPersonId, reqVO.getOldPersonId())
                .eqIfPresent(IotDevicePersonLogDO::getOldPersonIds, reqVO.getOldPersonIds())
                .eqIfPresent(IotDevicePersonLogDO::getNewPersonId, reqVO.getNewPersonId())
                .eqIfPresent(IotDevicePersonLogDO::getNewPersonIds, reqVO.getNewPersonIds())
                .eqIfPresent(IotDevicePersonLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDevicePersonLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDevicePersonLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDevicePersonLogDO::getId));
    }

    default List<IotDevicePersonLogDO> selectList(IotDevicePersonLogPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotDevicePersonLogDO>()
                .eqIfPresent(IotDevicePersonLogDO::getDeviceId, reqVO.getDeviceId())
                .inIfPresent(IotDevicePersonLogDO::getDeviceId, reqVO.getDeviceIds())
                .eqIfPresent(IotDevicePersonLogDO::getOldPersonId, reqVO.getOldPersonId())
                .eqIfPresent(IotDevicePersonLogDO::getOldPersonIds, reqVO.getOldPersonIds())
                .eqIfPresent(IotDevicePersonLogDO::getNewPersonId, reqVO.getNewPersonId())
                .eqIfPresent(IotDevicePersonLogDO::getNewPersonIds, reqVO.getNewPersonIds())
                .eqIfPresent(IotDevicePersonLogDO::getReason, reqVO.getReason())
                .eqIfPresent(IotDevicePersonLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDevicePersonLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDevicePersonLogDO::getId));
    }

}