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

import java.util.List;

/**
 * 采购收款明细 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface BpmOAProcurePayItemMapper extends BaseMapperX<BpmOAProcurePayItemDO> {

    default PageResult<BpmOAProcurePayItemDO> selectPage(BpmOAProcurePayItemPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOAProcurePayItemDO>()
                .eqIfPresent(BpmOAProcurePayItemDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BpmOAProcurePayItemDO::getBpmOaProcurePayId, reqVO.getBpmOaProcurePayId())
                .eqIfPresent(BpmOAProcurePayItemDO::getBpmOaProcureId, reqVO.getBpmOaProcureId())
                .eqIfPresent(BpmOAProcurePayItemDO::getPayee, reqVO.getPayee())
                .eqIfPresent(BpmOAProcurePayItemDO::getPayeeNumber, reqVO.getPayeeNumber())
                .betweenIfPresent(BpmOAProcurePayItemDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOAProcurePayItemDO::getId));
    }

    /**
     * 通过采购支付id获取想去和采购申请记录
     *
     * @param procurePayId
     * @return
     */
    List<BpmOAProcurePayItemRespVO> getByProcurePayId(@Param("procurePayId") Long procurePayId);
}