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

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.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.vo.orderObjective.*;

/**
 * 订单目的仓库 Mapper
 * @author 系统管理员
 */
@Mapper
public interface OrderObjectiveMapper extends AbstractMapper<OrderObjectiveDO> {
    @Override
    default PageResult<OrderObjectiveDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderObjectiveQueryVO) {
            OrderObjectiveQueryVO vo = (OrderObjectiveQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderObjectiveDO>()
                .eqIfPresent(OrderObjectiveDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderObjectiveDO::getObjectiveId, vo.getObjectiveId())
                .eqIfPresent(OrderObjectiveDO::getObjective, vo.getObjective())
                .eqIfPresent(OrderObjectiveDO::getType, vo.getType())
                .eqIfPresent(OrderObjectiveDO::getIsThis, vo.getIsThis())
                .betweenIfPresent(OrderObjectiveDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderObjectiveDO::getId));
        }

        return null;
    }

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

        return null;
    }
}
