package com.zt.plat.module.qms.resource.material.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.material.controller.vo.*;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 物料大类 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface MaterialProductMapper extends BaseMapperX<MaterialProductDO> {

    default PageResult<MaterialProductDO> selectPage(MaterialProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialProductDO>()
                .eqIfPresent(MaterialProductDO::getParentId, reqVO.getParentId())
                .likeIfPresent(MaterialProductDO::getIdPath, reqVO.getIdPath())
                .eqIfPresent(MaterialProductDO::getNodeType, reqVO.getNodeType())
                .likeIfPresent(MaterialProductDO::getName, reqVO.getName())
                .eqIfPresent(MaterialProductDO::getCustomConfig, reqVO.getCustomConfig())
                .eqIfPresent(MaterialProductDO::getCustomForm, reqVO.getCustomForm())
                .eqIfPresent(MaterialProductDO::getCustomData, reqVO.getCustomData())
                .eqIfPresent(MaterialProductDO::getTag, reqVO.getTag())
                .eqIfPresent(MaterialProductDO::getLabelTemplateKey, reqVO.getLabelTemplateKey())
                .eqIfPresent(MaterialProductDO::getModelNo, reqVO.getModelNo())
                .eqIfPresent(MaterialProductDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(MaterialProductDO::getParameter, reqVO.getParameter())
                .eqIfPresent(MaterialProductDO::getManufacturer, reqVO.getManufacturer())
                .eqIfPresent(MaterialProductDO::getUnit, reqVO.getUnit())
                .eqIfPresent(MaterialProductDO::getEnablePartial, reqVO.getEnablePartial())
                .eqIfPresent(MaterialProductDO::getDue, reqVO.getDue())
                .eqIfPresent(MaterialProductDO::getOpenDueFlag, reqVO.getOpenDueFlag())
                .eqIfPresent(MaterialProductDO::getOpenDueAfter, reqVO.getOpenDueAfter())
                .eqIfPresent(MaterialProductDO::getHazardous, reqVO.getHazardous())
                .eqIfPresent(MaterialProductDO::getStandardSolutionFlag, reqVO.getStandardSolutionFlag())
                .eqIfPresent(MaterialProductDO::getStandardMaterialFlag, reqVO.getStandardMaterialFlag())
                .eqIfPresent(MaterialProductDO::getReviewDue, reqVO.getReviewDue())
                .eqIfPresent(MaterialProductDO::getSortNo, reqVO.getSortNo())
                .eqIfPresent(MaterialProductDO::getCancelFlag, reqVO.getCancelFlag())
                .eqIfPresent(MaterialProductDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(MaterialProductDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(MaterialProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialProductDO::getId));
    }

}