package cn.iocoder.yudao.module.flow.dal.mysql.outboundgoods;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.flow.dal.dataobject.outboundgoods.OutboundGoodsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.flow.controller.admin.outboundgoods.vo.*;

/**
 * 出库单商品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OutboundGoodsMapper extends BaseMapperX<OutboundGoodsDO> {

    default PageResult<OutboundGoodsDO> selectPage(OutboundGoodsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OutboundGoodsDO>()
                .eqIfPresent(OutboundGoodsDO::getBindId, reqVO.getBindId())
                .eqIfPresent(OutboundGoodsDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(OutboundGoodsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(OutboundGoodsDO::getOutBoundId, reqVO.getOutBoundId())
                .eqIfPresent(OutboundGoodsDO::getHarvestBatchId, reqVO.getHarvestBatchId())
                .eqIfPresent(OutboundGoodsDO::getIdentityCodeNum, reqVO.getIdentityCodeNum())
                .eqIfPresent(OutboundGoodsDO::getGoodsUnit, reqVO.getGoodsUnit())
                .eqIfPresent(OutboundGoodsDO::getGoodsWeight, reqVO.getGoodsWeight())
                .eqIfPresent(OutboundGoodsDO::getGoodsUnitPrice, reqVO.getGoodsUnitPrice())
                .eqIfPresent(OutboundGoodsDO::getTotalPrice, reqVO.getTotalPrice())
                .betweenIfPresent(OutboundGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OutboundGoodsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(OutboundGoodsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .orderByDesc(OutboundGoodsDO::getId));
    }

    default List<OutboundGoodsDO> selectList(OutboundGoodsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OutboundGoodsDO>()
                .eqIfPresent(OutboundGoodsDO::getBindId, reqVO.getBindId())
                .eqIfPresent(OutboundGoodsDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(OutboundGoodsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(OutboundGoodsDO::getOutBoundId, reqVO.getOutBoundId())
                .eqIfPresent(OutboundGoodsDO::getHarvestBatchId, reqVO.getHarvestBatchId())
                .eqIfPresent(OutboundGoodsDO::getIdentityCodeNum, reqVO.getIdentityCodeNum())
                .eqIfPresent(OutboundGoodsDO::getGoodsUnit, reqVO.getGoodsUnit())
                .eqIfPresent(OutboundGoodsDO::getGoodsWeight, reqVO.getGoodsWeight())
                .eqIfPresent(OutboundGoodsDO::getGoodsUnitPrice, reqVO.getGoodsUnitPrice())
                .eqIfPresent(OutboundGoodsDO::getTotalPrice, reqVO.getTotalPrice())
                .betweenIfPresent(OutboundGoodsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OutboundGoodsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(OutboundGoodsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .orderByDesc(OutboundGoodsDO::getId));
    }

}
