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

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

/**
 * 告警设置 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotAlarmSettingMapper extends BaseMapperX<IotAlarmSettingDO> {

    default PageResult<IotAlarmSettingDO> selectPageDevice(IotAlarmSettingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotAlarmSettingDO>()
                .eqIfPresent(IotAlarmSettingDO::getClassifyId, reqVO.getClassifyId())
                .likeIfPresent(IotAlarmSettingDO::getClassifyName, reqVO.getClassifyName())
                .eqIfPresent(IotAlarmSettingDO::getDeviceId, reqVO.getDeviceId())
                .likeIfPresent(IotAlarmSettingDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(IotAlarmSettingDO::getMaxValue, reqVO.getMaxValue())
                .eqIfPresent(IotAlarmSettingDO::getMinValue, reqVO.getMinValue())
                .betweenIfPresent(IotAlarmSettingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(IotAlarmSettingDO::getAlarmProperty, reqVO.getAlarmProperty())
                .isNotNull(IotAlarmSettingDO::getDeviceId)
                .orderByDesc(IotAlarmSettingDO::getId));
    }

    default PageResult<IotAlarmSettingDO> selectPageNoDevice(IotAlarmSettingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotAlarmSettingDO>()
                .eqIfPresent(IotAlarmSettingDO::getClassifyId, reqVO.getClassifyId())
                .likeIfPresent(IotAlarmSettingDO::getClassifyName, reqVO.getClassifyName())
                .likeIfPresent(IotAlarmSettingDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(IotAlarmSettingDO::getMaxValue, reqVO.getMaxValue())
                .eqIfPresent(IotAlarmSettingDO::getMinValue, reqVO.getMinValue())
                .betweenIfPresent(IotAlarmSettingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(IotAlarmSettingDO::getAlarmProperty, reqVO.getAlarmProperty())
                .isNull(IotAlarmSettingDO::getDeviceId)
                .orderByDesc(IotAlarmSettingDO::getId));
    }

}
