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

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.pms.controller.admin.yanfan.vo.DevicePageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.yanfan.YfDeviceDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 设备 Mapper
 *
 * @author 李鹏辉
 */
@Mapper
public interface YfDeviceMapper extends BaseMapperX<YfDeviceDO> {

    default PageResult<YfDeviceDO> selectPage(DevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<YfDeviceDO>()
                .likeIfPresent(YfDeviceDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(YfDeviceDO::getProductId, reqVO.getProductId())
                .likeIfPresent(YfDeviceDO::getProductName, reqVO.getProductName())
                .likeIfPresent(YfDeviceDO::getTenantName, reqVO.getTenantName())
                .eqIfPresent(YfDeviceDO::getSerialNumber, reqVO.getSerialNumber())
                .eqIfPresent(YfDeviceDO::getGwDevCode, reqVO.getGwDevCode())
                .eqIfPresent(YfDeviceDO::getFirmwareVersion, reqVO.getFirmwareVersion())
                .eqIfPresent(YfDeviceDO::getStatus, reqVO.getStatus())
                .eqIfPresent(YfDeviceDO::getRssi, reqVO.getRssi())
                .eqIfPresent(YfDeviceDO::getIsShadow, reqVO.getIsShadow())
                .eqIfPresent(YfDeviceDO::getLocationWay, reqVO.getLocationWay())
                .eqIfPresent(YfDeviceDO::getThingsModelValue, reqVO.getThingsModelValue())
                .eqIfPresent(YfDeviceDO::getNetworkAddress, reqVO.getNetworkAddress())
                .eqIfPresent(YfDeviceDO::getNetworkIp, reqVO.getNetworkIp())
                .eqIfPresent(YfDeviceDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(YfDeviceDO::getLatitude, reqVO.getLatitude())
                .betweenIfPresent(YfDeviceDO::getActiveTime, reqVO.getActiveTime())
                .eqIfPresent(YfDeviceDO::getSummary, reqVO.getSummary())
                .eqIfPresent(YfDeviceDO::getImgUrl, reqVO.getImgUrl())
                .eqIfPresent(YfDeviceDO::getDelFlag, reqVO.getDelFlag())
                .eqIfPresent(YfDeviceDO::getCreateBy, reqVO.getCreateBy())
                //.betweenIfPresent(YfDeviceDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(YfDeviceDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(YfDeviceDO::getRemark, reqVO.getRemark())
                .eqIfPresent(YfDeviceDO::getIsSimulate, reqVO.getIsSimulate())
                .eqIfPresent(YfDeviceDO::getSlaveId, reqVO.getSlaveId())
//                .eqIfPresent(YfDeviceDO::getClientId, reqVO.getClientId())
                .eqIfPresent(YfDeviceDO::getPostDev, reqVO.getPostDev())
                .eqIfPresent(YfDeviceDO::getGetDev, reqVO.getGetDev())
                .eqIfPresent(YfDeviceDO::getMqttstats, reqVO.getMqttstats())
                .orderByDesc(YfDeviceDO::getDeviceId));
    }

}
