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

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderExceptionResult.OrderExceptionResultDO;
import cn.iocoder.yudao.module.order.vo.orderExceptionResult.OrderExceptionResultQueryVO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 异常处理记录 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface OrderExceptionResultMapper extends AbstractMapper<OrderExceptionResultDO> {
    @Override
    default PageResult<OrderExceptionResultDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderExceptionResultQueryVO) {
            OrderExceptionResultQueryVO vo = (OrderExceptionResultQueryVO) object;
            return selectPage(page, new LambdaQuery<OrderExceptionResultDO>()
                    .eqIfPresent(OrderExceptionResultDO::getOrderExceptionId, vo.getOrderExceptionId())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerId, vo.getHandlerId())
                    .betweenIfPresent(OrderExceptionResultDO::getHandlerTime, vo.getBeginHandlerTime(), vo.getEndHandlerTime())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerResult, vo.getHandlerResult())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerRemark, vo.getHandlerRemark())
                    .betweenIfPresent(OrderExceptionResultDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderExceptionResultDO::getId));
        }

        return null;
    }

    @Override
    default List<OrderExceptionResultDO> selectList(Object object) {
        if (object instanceof OrderExceptionResultQueryVO) {
            OrderExceptionResultQueryVO vo = (OrderExceptionResultQueryVO) object;
            return selectList(new LambdaQuery<OrderExceptionResultDO>()
                    .eqIfPresent(OrderExceptionResultDO::getOrderExceptionId, vo.getOrderExceptionId())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerId, vo.getHandlerId())
                    .betweenIfPresent(OrderExceptionResultDO::getHandlerTime, vo.getBeginHandlerTime(), vo.getEndHandlerTime())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerResult, vo.getHandlerResult())
                    .eqIfPresent(OrderExceptionResultDO::getHandlerRemark, vo.getHandlerRemark())
                    .betweenIfPresent(OrderExceptionResultDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderExceptionResultDO::getId));
        }

        return null;
    }
}
