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

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

import java.util.List;

/**
 * 设备分类公共模板属性 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotDeviceCategoryTemplateAttrsMapper extends BaseMapperX<IotDeviceCategoryTemplateAttrsDO> {

    default PageResult<IotDeviceCategoryTemplateAttrsDO> selectPage(IotDeviceCategoryTemplateAttrsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceCategoryTemplateAttrsDO>()
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDeviceCategoryId, reqVO.getDeviceCategoryId())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getTemplateId, reqVO.getTemplateId())
                .likeIfPresent(IotDeviceCategoryTemplateAttrsDO::getName, reqVO.getName())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getCode, reqVO.getCode())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getType, reqVO.getType())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getRequiredFlag, reqVO.getRequiredFlag())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDefaultValue, reqVO.getDefaultValue())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getUnit, reqVO.getUnit())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getSort, reqVO.getSort())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getSelectOptions, reqVO.getSelectOptions())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(IotDeviceCategoryTemplateAttrsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceCategoryTemplateAttrsDO::getId));
    }

    default List<IotDeviceCategoryTemplateAttrsDO> selectList(IotDeviceCategoryTemplateAttrsPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotDeviceCategoryTemplateAttrsDO>()
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDeviceCategoryId, reqVO.getDeviceCategoryId())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getTemplateId, reqVO.getTemplateId())
                .likeIfPresent(IotDeviceCategoryTemplateAttrsDO::getName, reqVO.getName())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getCode, reqVO.getCode())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getType, reqVO.getType())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getRequiredFlag, reqVO.getRequiredFlag())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDefaultValue, reqVO.getDefaultValue())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getUnit, reqVO.getUnit())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getSort, reqVO.getSort())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getSelectOptions, reqVO.getSelectOptions())
                .eqIfPresent(IotDeviceCategoryTemplateAttrsDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(IotDeviceCategoryTemplateAttrsDO::getCreateTime, reqVO.getCreateTime()));
    }

    default List<IotDeviceCategoryTemplateAttrsDO> selectList(Long deviceCategoryId) {
        return selectList(IotDeviceCategoryTemplateAttrsDO::getDeviceCategoryId, deviceCategoryId);
    }

}