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

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

/**
 * 订单发货人信息 Mapper
 * @author 系统管理员
 */
@Mapper
public interface OrderConsignorMapper extends AbstractMapper<OrderConsignorDO> {
    @Override
    default PageResult<OrderConsignorDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderConsignorQueryVO) {
            OrderConsignorQueryVO vo = (OrderConsignorQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderConsignorDO>()
                .eqIfPresent(OrderConsignorDO::getRelationId, vo.getRelationId())
                .eqIfPresent(OrderConsignorDO::getOrderId, vo.getOrderId())
                .likeIfPresent(OrderConsignorDO::getName, vo.getName())
                .likeIfPresent(OrderConsignorDO::getNameEn, vo.getNameEn())
                .eqIfPresent(OrderConsignorDO::getPhone, vo.getPhone())
                .eqIfPresent(OrderConsignorDO::getEmail, vo.getEmail())
                .eqIfPresent(OrderConsignorDO::getCompany, vo.getCompany())
                .eqIfPresent(OrderConsignorDO::getCompanyEn, vo.getCompanyEn())
                .eqIfPresent(OrderConsignorDO::getCartId, vo.getCartId())
                .eqIfPresent(OrderConsignorDO::getCountryAbbreviation, vo.getCountryAbbreviation())
                .eqIfPresent(OrderConsignorDO::getCountryCode, vo.getCountryCode())
                .eqIfPresent(OrderConsignorDO::getCustomerId, vo.getCustomerId())
                .eqIfPresent(OrderConsignorDO::getCustomerContactsId, vo.getCustomerContactsId())
                .eqIfPresent(OrderConsignorDO::getIsDevolve, vo.getIsDevolve())
                .betweenIfPresent(OrderConsignorDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderConsignorDO::getId));
        }

        return null;
    }

    @Override
    default List<OrderConsignorDO> selectList(Object object) {
        if (object instanceof OrderConsignorQueryVO) {
            OrderConsignorQueryVO vo = (OrderConsignorQueryVO)object;
            return selectList(new LambdaQuery<OrderConsignorDO>()
                .eqIfPresent(OrderConsignorDO::getRelationId, vo.getRelationId())
                .eqIfPresent(OrderConsignorDO::getOrderId, vo.getOrderId())
                .likeIfPresent(OrderConsignorDO::getName, vo.getName())
                .likeIfPresent(OrderConsignorDO::getNameEn, vo.getNameEn())
                .eqIfPresent(OrderConsignorDO::getPhone, vo.getPhone())
                .eqIfPresent(OrderConsignorDO::getEmail, vo.getEmail())
                .eqIfPresent(OrderConsignorDO::getCompany, vo.getCompany())
                .eqIfPresent(OrderConsignorDO::getCompanyEn, vo.getCompanyEn())
                .eqIfPresent(OrderConsignorDO::getCartId, vo.getCartId())
                .eqIfPresent(OrderConsignorDO::getCountryAbbreviation, vo.getCountryAbbreviation())
                .eqIfPresent(OrderConsignorDO::getCountryCode, vo.getCountryCode())
                .eqIfPresent(OrderConsignorDO::getCustomerId, vo.getCustomerId())
                .eqIfPresent(OrderConsignorDO::getCustomerContactsId, vo.getCustomerContactsId())
                .eqIfPresent(OrderConsignorDO::getIsDevolve, vo.getIsDevolve())
                .betweenIfPresent(OrderConsignorDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                    .orderByDesc(OrderConsignorDO::getId));
        }

        return null;
    }
}
