package cn.iocoder.yudao.module.iot.dal.mysql.alert;

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.iot.dal.dataobject.alert.AlertDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.iot.controller.admin.alert.vo.*;

/**
 * 告警配置 Mapper
 *
 * @author 内蒙必硕
 */
@Mapper
public interface AlertMapper extends BaseMapperX<AlertDO> {

    default PageResult<AlertDO> selectPage(AlertPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AlertDO>()
                .eqIfPresent(AlertDO::getAlertCode, reqVO.getAlertCode())
                .likeIfPresent(AlertDO::getAlertName, reqVO.getAlertName())
                .eqIfPresent(AlertDO::getAlertType, reqVO.getAlertType())
                .eqIfPresent(AlertDO::getAlertLevel, reqVO.getAlertLevel())
                .eqIfPresent(AlertDO::getContent, reqVO.getContent())
                .eqIfPresent(AlertDO::getConditionInfo, reqVO.getConditionInfo())
                .eqIfPresent(AlertDO::getConditionFormula, reqVO.getConditionFormula())
                .eqIfPresent(AlertDO::getAlertAudio, reqVO.getAlertAudio())
                .eqIfPresent(AlertDO::getIsRepeat, reqVO.getIsRepeat())
                .eqIfPresent(AlertDO::getNoRepeatDuration, reqVO.getNoRepeatDuration())
                .eqIfPresent(AlertDO::getIsEnable, reqVO.getIsEnable())
                .betweenIfPresent(AlertDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AlertDO::getId));
    }

}