package cn.iocoder.yudao.module.pms.dal.mysql.qhse.danger;

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.qhse.danger.vo.IotDangerSourcePageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.danger.IotDangerSourceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Set;

/**
 * 危险源 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotDangerSourceMapper extends BaseMapperX<IotDangerSourceDO> {

    default PageResult<IotDangerSourceDO> selectPage(IotDangerSourcePageReqVO reqVO, Set<Long> ids) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDangerSourceDO>()
                .eqIfPresent(IotDangerSourceDO::getRegion, reqVO.getRegion())
                .eqIfPresent(IotDangerSourceDO::getElementDescription, reqVO.getElementDescription())
                .eqIfPresent(IotDangerSourceDO::getMaybeResult, reqVO.getMaybeResult())
                .eqIfPresent(IotDangerSourceDO::getEvalKn, reqVO.getEvalKn())
                .eqIfPresent(IotDangerSourceDO::getEvalYz, reqVO.getEvalYz())
                .eqIfPresent(IotDangerSourceDO::getEvalFxz, reqVO.getEvalFxz())
                .eqIfPresent(IotDangerSourceDO::getRiskGrade, reqVO.getRiskGrade())
                .eqIfPresent(IotDangerSourceDO::getControlMethod, reqVO.getControlMethod())
                .inIfPresent(IotDangerSourceDO::getDeptId, ids)
                .eqIfPresent(IotDangerSourceDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotDangerSourceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDangerSourceDO::getId));
    }
    default List<IotDangerSourceDO> selectListByDept(IotDangerSourcePageReqVO reqVO, Set<Long> ids) {
        return selectList(new LambdaQueryWrapperX<IotDangerSourceDO>()
                .eq(IotDangerSourceDO::getDeleted, false)
                .inIfPresent(IotDangerSourceDO::getDeptId, ids));
    }
}