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

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

/**
 * 物模型 Mapper
 *
 * @author 李鹏辉
 */
@Mapper
public interface ThingsModelMapper extends BaseMapperX<ThingsModelDO> {

    default PageResult<ThingsModelDO> selectPage(ThingsModelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ThingsModelDO>()
                .likeIfPresent(ThingsModelDO::getModelName, reqVO.getModelName())
                .eqIfPresent(ThingsModelDO::getProductId, reqVO.getProductId())
                .likeIfPresent(ThingsModelDO::getProductName, reqVO.getProductName())
                .likeIfPresent(ThingsModelDO::getTenantName, reqVO.getTenantName())
                .eqIfPresent(ThingsModelDO::getIdentifier, reqVO.getIdentifier())
                .eqIfPresent(ThingsModelDO::getType, reqVO.getType())
                .eqIfPresent(ThingsModelDO::getDatatype, reqVO.getDatatype())
                .eqIfPresent(ThingsModelDO::getSpecs, reqVO.getSpecs())
                .eqIfPresent(ThingsModelDO::getIsChart, reqVO.getIsChart())
                .eqIfPresent(ThingsModelDO::getIsMonitor, reqVO.getIsMonitor())
                .eqIfPresent(ThingsModelDO::getIsHistory, reqVO.getIsHistory())
                .eqIfPresent(ThingsModelDO::getIsReadonly, reqVO.getIsReadonly())
                .eqIfPresent(ThingsModelDO::getIsSharePerm, reqVO.getIsSharePerm())
                .eqIfPresent(ThingsModelDO::getModelOrder, reqVO.getModelOrder())
                .eqIfPresent(ThingsModelDO::getDelFlag, reqVO.getDelFlag())
                .eqIfPresent(ThingsModelDO::getCreateBy, reqVO.getCreateBy())
//                .betweenIfPresent(ThingsModelDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ThingsModelDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(ThingsModelDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ThingsModelDO::getTempSlaveId, reqVO.getTempSlaveId())
                .eqIfPresent(ThingsModelDO::getFormula, reqVO.getFormula())
                .eqIfPresent(ThingsModelDO::getReverseFormula, reqVO.getReverseFormula())
                .eqIfPresent(ThingsModelDO::getRegAddr, reqVO.getRegAddr())
                .eqIfPresent(ThingsModelDO::getBitOption, reqVO.getBitOption())
                .eqIfPresent(ThingsModelDO::getValueType, reqVO.getValueType())
                .eqIfPresent(ThingsModelDO::getIsParams, reqVO.getIsParams())
                .eqIfPresent(ThingsModelDO::getQuantity, reqVO.getQuantity())
                .eqIfPresent(ThingsModelDO::getCode, reqVO.getCode())
                .eqIfPresent(ThingsModelDO::getParseType, reqVO.getParseType())
                .eqIfPresent(ThingsModelDO::getIsApp, reqVO.getIsApp())
                .orderByDesc(ThingsModelDO::getModelId));
    }

}
