package com.zt.plat.module.contractorder.dal.mysql.contractreceivesend;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;

import com.zt.plat.module.contractorder.api.vo.contract.ContractReceiveSendPageReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contractreceivesend.ContractReceiveSendDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 收发货规则 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface ContractReceiveSendMapper extends BaseMapperX<ContractReceiveSendDO> {

    default PageResult<ContractReceiveSendDO> selectPage(ContractReceiveSendPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ContractReceiveSendDO>()
                .likeIfPresent(ContractReceiveSendDO::getMaterialName, reqVO.getMaterialName())
                .eqIfPresent(ContractReceiveSendDO::getMaterialNumber, reqVO.getMaterialNumber())
                .eqIfPresent(ContractReceiveSendDO::getElementAbbreviation, reqVO.getElementAbbreviation())
                .likeIfPresent(ContractReceiveSendDO::getElementName, reqVO.getElementName())
                .eqIfPresent(ContractReceiveSendDO::getElementNumber, reqVO.getElementNumber())
                .eqIfPresent(ContractReceiveSendDO::getType, reqVO.getType())
                .eqIfPresent(ContractReceiveSendDO::getRule, reqVO.getRule())
                .eqIfPresent(ContractReceiveSendDO::getRangeWay, reqVO.getRangeWay())
                .eqIfPresent(ContractReceiveSendDO::getGradeDown, reqVO.getGradeDown())
                .eqIfPresent(ContractReceiveSendDO::getGradeUp, reqVO.getGradeUp())
                .eqIfPresent(ContractReceiveSendDO::getContractId, reqVO.getContractId())
                .betweenIfPresent(ContractReceiveSendDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ContractReceiveSendDO::getId));
    }

}