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

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

import java.util.List;

/**
 * PMS 物料领用明细 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotMaterialRequisitionDetailMapper extends BaseMapperX<IotMaterialRequisitionDetailDO> {

    default PageResult<IotMaterialRequisitionDetailDO> selectPage(IotMaterialRequisitionDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotMaterialRequisitionDetailDO>()
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRequisitionId, reqVO.getRequisitionId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getCostCenterId, reqVO.getCostCenterId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getMaterialId, reqVO.getMaterialId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(IotMaterialRequisitionDetailDO::getMaterialName, reqVO.getMaterialName())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRequisitionQuantity, reqVO.getRequisitionQuantity())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getUnit, reqVO.getUnit())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getUnitPrice, reqVO.getUnitPrice())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getSort, reqVO.getSort())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotMaterialRequisitionDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotMaterialRequisitionDetailDO::getId));
    }

    default List<IotMaterialRequisitionDetailDO> selectList(IotMaterialRequisitionDetailPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotMaterialRequisitionDetailDO>()
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRequisitionId, reqVO.getRequisitionId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getCostCenterId, reqVO.getCostCenterId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getMaterialId, reqVO.getMaterialId())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(IotMaterialRequisitionDetailDO::getMaterialName, reqVO.getMaterialName())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRequisitionQuantity, reqVO.getRequisitionQuantity())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getUnit, reqVO.getUnit())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getUnitPrice, reqVO.getUnitPrice())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getSort, reqVO.getSort())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotMaterialRequisitionDetailDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotMaterialRequisitionDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotMaterialRequisitionDetailDO::getId));
    }

}