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

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

/**
 * IoT通用物模型 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ThingModelCommonMapper extends BaseMapperX<ThingModelCommonDO> {

    default PageResult<ThingModelCommonDO> selectPage(ThingModelCommonPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ThingModelCommonDO>()
                .eqIfPresent(ThingModelCommonDO::getIdentifier, reqVO.getIdentifier())
                .likeIfPresent(ThingModelCommonDO::getName, reqVO.getName())
                .eqIfPresent(ThingModelCommonDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ThingModelCommonDO::getType, reqVO.getType())
                .eqIfPresent(ThingModelCommonDO::getProperty, reqVO.getProperty())
                .eqIfPresent(ThingModelCommonDO::getEvent, reqVO.getEvent())
                .eqIfPresent(ThingModelCommonDO::getService, reqVO.getService())
                .betweenIfPresent(ThingModelCommonDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ThingModelCommonDO::getId));
    }

}