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

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.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.pms.controller.admin.iotmodeltemplate.vo.IotModelTemplatePageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplate.IotModelTemplateDO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillOrderDO;
import org.apache.ibatis.annotations.Mapper;

import javax.validation.constraints.Negative;
import java.util.Collection;
import java.util.List;

/**
 * PMS 功能优化 设备模板 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface IotModelTemplateMapper extends BaseMapperX<IotModelTemplateDO> {

    default PageResult<IotModelTemplateDO> selectPage(IotModelTemplatePageReqVO reqVO,Collection<Long> deptIds) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotModelTemplateDO>()
                .inIfPresent(IotModelTemplateDO::getDeviceCategoryId, deptIds)
                .likeIfPresent(IotModelTemplateDO::getName, reqVO.getName())
                .eqIfPresent(IotModelTemplateDO::getCode, reqVO.getCode())
                .eqIfPresent(IotModelTemplateDO::getAttrs, reqVO.getAttrs())
                .eqIfPresent(IotModelTemplateDO::getDescription, reqVO.getDescription())
                .eqIfPresent(IotModelTemplateDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotModelTemplateDO::getSort, reqVO.getSort())
                .eqIfPresent(IotModelTemplateDO::getRemark, reqVO.getRemark())
                .eqIfPresent(IotModelTemplateDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(IotModelTemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotModelTemplateDO::getId));
    }

    default IotModelTemplateDO selectByDeviceCategoryId(Long deviceCategoryId){
        return selectOne(IotModelTemplateDO::getDeviceCategoryId, deviceCategoryId);
    };

    List<IotModelTemplateDO> modelList();
    @TenantIgnore
    List<IotModelTemplateDO> isRelated(IotModelTemplatePageReqVO reqVO);
}