package cn.iocoder.yudao.module.order.dal.mysql.orderDeparture;

import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.module.order.dal.dataobject.orderDeparture.OrderDepartureDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.vo.orderDeparture.*;

/**
 * 订单始发仓库 Mapper
 * @author 系统管理员
 */
@Mapper
public interface OrderDepartureMapper extends AbstractMapper<OrderDepartureDO> {
    @Override
    default PageResult<OrderDepartureDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderDepartureQueryVO) {
            OrderDepartureQueryVO vo = (OrderDepartureQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderDepartureDO>()
                .eqIfPresent(OrderDepartureDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderDepartureDO::getDepartureId, vo.getDepartureId())
                .eqIfPresent(OrderDepartureDO::getDeparture, vo.getDeparture())
                .eqIfPresent(OrderDepartureDO::getType, vo.getType())
                .eqIfPresent(OrderDepartureDO::getIsThis, vo.getIsThis())
                .betweenIfPresent(OrderDepartureDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderDepartureDO::getId));
        }

        return null;
    }

    @Override
    default List<OrderDepartureDO> selectList(Object object) {
        if (object instanceof OrderDepartureQueryVO) {
            OrderDepartureQueryVO vo = (OrderDepartureQueryVO)object;
            return selectList(new LambdaQuery<OrderDepartureDO>()
                .eqIfPresent(OrderDepartureDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderDepartureDO::getDepartureId, vo.getDepartureId())
                .eqIfPresent(OrderDepartureDO::getDeparture, vo.getDeparture())
                .eqIfPresent(OrderDepartureDO::getType, vo.getType())
                .eqIfPresent(OrderDepartureDO::getIsThis, vo.getIsThis())
                .betweenIfPresent(OrderDepartureDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderDepartureDO::getId));
        }

        return null;
    }
}
