package cn.iocoder.yudao.module.asset.dal.mysql.delivery;

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.asset.controller.admin.delivery.vo.DeliveryOrderPageReqVO;
import cn.iocoder.yudao.module.asset.dal.dataobject.delivery.DeliveryOrderDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface DeliveryOrderMapper extends BaseMapperX<DeliveryOrderDO> {

    default PageResult<DeliveryOrderDO> selectPage(DeliveryOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeliveryOrderDO>()
                .likeIfPresent(DeliveryOrderDO::getOrderCode, reqVO.getOrderCode())
                .likeIfPresent(DeliveryOrderDO::getTaskCode, reqVO.getTaskCode())
                .likeIfPresent(DeliveryOrderDO::getContractCode, reqVO.getContractCode())
                .likeIfPresent(DeliveryOrderDO::getProjectName, reqVO.getProjectName())
                .likeIfPresent(DeliveryOrderDO::getCustomerName, reqVO.getCustomerName())
                .likeIfPresent(DeliveryOrderDO::getDeliveryPerson, reqVO.getDeliveryPerson())
                .eqIfPresent(DeliveryOrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(DeliveryOrderDO::getDeliveryDate, reqVO.getDeliveryDate())
                .betweenIfPresent(DeliveryOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeliveryOrderDO::getId));
    }

}
