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

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

/**
 * 订单控货日志 Mapper
 * @author 江楠
 */
@Mapper
public interface OrderControlLogMapper extends AbstractMapper<OrderControlLogDO> {
    @Override
    default PageResult<OrderControlLogDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderControlLogQueryVO) {
            OrderControlLogQueryVO vo = (OrderControlLogQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderControlLogDO>()
                .eqIfPresent(OrderControlLogDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderControlLogDO::getRequestUrl, vo.getRequestUrl())
                .eqIfPresent(OrderControlLogDO::getTypeKey, vo.getTypeKey())
                .eqIfPresent(OrderControlLogDO::getType, vo.getType())
                .eqIfPresent(OrderControlLogDO::getMsg, vo.getMsg())
                .eqIfPresent(OrderControlLogDO::getUserType, vo.getUserType())
                .eqIfPresent(OrderControlLogDO::getApprovalId, vo.getApprovalId())
                .likeIfPresent(OrderControlLogDO::getCreatorName, vo.getCreatorName())
                .betweenIfPresent(OrderControlLogDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderControlLogDO::getId));
        }

        return null;
    }

    @Override
    default List<OrderControlLogDO> selectList(Object object) {
        if (object instanceof OrderControlLogQueryVO) {
            OrderControlLogQueryVO vo = (OrderControlLogQueryVO)object;
            return selectList(new LambdaQuery<OrderControlLogDO>()
                .eqIfPresent(OrderControlLogDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderControlLogDO::getRequestUrl, vo.getRequestUrl())
                .eqIfPresent(OrderControlLogDO::getTypeKey, vo.getTypeKey())
                .eqIfPresent(OrderControlLogDO::getType, vo.getType())
                .eqIfPresent(OrderControlLogDO::getMsg, vo.getMsg())
                .eqIfPresent(OrderControlLogDO::getUserType, vo.getUserType())
                .eqIfPresent(OrderControlLogDO::getApprovalId, vo.getApprovalId())
                .likeIfPresent(OrderControlLogDO::getCreatorName, vo.getCreatorName())
                .betweenIfPresent(OrderControlLogDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderControlLogDO::getId));
        }

        return null;
    }
}
