package com.zt.plat.module.qms.resource.device.dal.mapper;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceProductPageReqVO;
import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceProductDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 设备-设备大类 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface DeviceProductMapper extends BaseMapperX<DeviceProductDO> {

    default PageResult<DeviceProductDO> selectPage(DeviceProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceProductDO>()
                .eqIfPresent(DeviceProductDO::getParentId, reqVO.getParentId())
                .likeIfPresent(DeviceProductDO::getIdPath, reqVO.getIdPath())
                .eqIfPresent(DeviceProductDO::getNodeType, reqVO.getNodeType())
                .eqIfPresent(DeviceProductDO::getLeafFlag, reqVO.getLeafFlag())
                .likeIfPresent(DeviceProductDO::getName, reqVO.getName())
                .eqIfPresent(DeviceProductDO::getCustomConfig, reqVO.getCustomConfig())
                .eqIfPresent(DeviceProductDO::getCustomForm, reqVO.getCustomForm())
                .eqIfPresent(DeviceProductDO::getCustomData, reqVO.getCustomData())
                .eqIfPresent(DeviceProductDO::getTag, reqVO.getTag())
                .eqIfPresent(DeviceProductDO::getLabelTemplateKey, reqVO.getLabelTemplateKey())
                .eqIfPresent(DeviceProductDO::getModelNo, reqVO.getModelNo())
                .eqIfPresent(DeviceProductDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(DeviceProductDO::getParameter, reqVO.getParameter())
                .eqIfPresent(DeviceProductDO::getDeviceUse, reqVO.getDeviceUse())
                .eqIfPresent(DeviceProductDO::getManufacturerNation, reqVO.getManufacturerNation())
                .eqIfPresent(DeviceProductDO::getManufacturer, reqVO.getManufacturer())
                .eqIfPresent(DeviceProductDO::getSortNo, reqVO.getSortNo())
                .eqIfPresent(DeviceProductDO::getCancelFlag, reqVO.getCancelFlag())
                .eqIfPresent(DeviceProductDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(DeviceProductDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DeviceProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceProductDO::getId));
    }

}