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

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

import java.util.Set;

/**
 * 设备分类属性公用模板 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotDeviceCategoryTemplateMapper extends BaseMapperX<IotDeviceCategoryTemplateDO> {

    default PageResult<IotDeviceCategoryTemplateDO> selectPage(IotDeviceCategoryTemplatePageReqVO reqVO, Set<Long> ids) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotDeviceCategoryTemplateDO>()
                // .eqIfPresent(IotDeviceCategoryTemplateDO::getDeviceCategoryId, reqVO.getDeviceCategoryId())
                .inIfPresent(IotDeviceCategoryTemplateDO::getDeviceCategoryId, ids)
                .likeIfPresent(IotDeviceCategoryTemplateDO::getName, reqVO.getName())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getCode, reqVO.getCode())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getAttrs, reqVO.getAttrs())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getDescription, reqVO.getDescription())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getSort, reqVO.getSort())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotDeviceCategoryTemplateDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(IotDeviceCategoryTemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotDeviceCategoryTemplateDO::getId));
    }

}