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.procure.BpmOAProcurePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcureDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * OA 采购申请 Mapper
 *
 * @author 姚君
 */
@Mapper
public interface BpmOAProcureMapper extends BaseMapperX<BpmOAProcureDO> {

    default PageResult<BpmOAProcureDO> selectPage(BpmOAProcurePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOAProcureDO>()
                .eqIfPresent(BpmOAProcureDO::getUserId, reqVO.getUserId())
                .eqIfPresent(BpmOAProcureDO::getReason, reqVO.getReason())
                .eqIfPresent(BpmOAProcureDO::getProcureType, reqVO.getProcureType())
                .betweenIfPresent(BpmOAProcureDO::getExpectedDeliveryDate, reqVO.getExpectedDeliveryDate())
                .eqIfPresent(BpmOAProcureDO::getProcureDetailJson, reqVO.getProcureDetailJson())
                .eqIfPresent(BpmOAProcureDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(BpmOAProcureDO::getFileItems, reqVO.getFileItems())
                .eqIfPresent(BpmOAProcureDO::getResult, reqVO.getResult())
                .eqIfPresent(BpmOAProcureDO::getProcessInstanceId, reqVO.getProcessInstanceId())
                .betweenIfPresent(BpmOAProcureDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOAProcureDO::getId));
    }

}
