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

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

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

        return null;
    }

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

        return null;
    }
}
