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

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

/**
 * 订单操作日志 Mapper
 * @author 郑屹
 */
@Mapper
public interface OrderOperateLogMapper extends AbstractMapper<OrderOperateLogDO> {
    @Override
    default PageResult<OrderOperateLogDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderOperateLogQueryVO) {
            OrderOperateLogQueryVO vo = (OrderOperateLogQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderOperateLogDO>()
                .eqIfPresent(OrderOperateLogDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderOperateLogDO::getBody, vo.getBody())
                .eqIfPresent(OrderOperateLogDO::getRequestUrl, vo.getRequestUrl())
                .eqIfPresent(OrderOperateLogDO::getType, vo.getType())
                .eqIfPresent(OrderOperateLogDO::getMsg, vo.getMsg())
                .eqIfPresent(OrderOperateLogDO::getNote, vo.getNote())
                .eqIfPresent(OrderOperateLogDO::getUserType, vo.getUserType())
                .betweenIfPresent(OrderOperateLogDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                .likeIfPresent(OrderOperateLogDO::getCreatorName, vo.getCreatorName())
                    .orderByDesc(OrderOperateLogDO::getId));
        }

        return null;
    }

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

        return null;
    }
}
