package cn.iocoder.yudao.module.bpm.dal.mysql.oa;

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.bpm.controller.admin.oa.vo.supplierprocurementplan.BpmOASupplierProcurementPlanItemPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASupplierProcurementPlanItemDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 供应商采购计划子 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface BpmOASupplierProcurementPlanItemMapper extends BaseMapperX<BpmOASupplierProcurementPlanItemDO> {

    default PageResult<BpmOASupplierProcurementPlanItemDO> selectPage(BpmOASupplierProcurementPlanItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOASupplierProcurementPlanItemDO>()
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getProcurementPlanId, reqVO.getProcurementPlanId())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getSupplierProductId, reqVO.getSupplierProductId())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getNum, reqVO.getNum())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getSupplierPrice, reqVO.getSupplierPrice())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getActualPrice, reqVO.getActualPrice())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getShippingAddress, reqVO.getShippingAddress())
                .eqIfPresent(BpmOASupplierProcurementPlanItemDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BpmOASupplierProcurementPlanItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOASupplierProcurementPlanItemDO::getId));
    }

    /**
     * 通过采购计划id获取采购计划子表
     *
     * @param procurementPlanId
     * @return
     */
    List<BpmOASupplierProcurementPlanItemDO> getByProcurementPlanId(@Param("procurementPlanId") Long procurementPlanId);
}
