package com.sckw.transport.repository;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sckw.transport.dao.KwtWaybillOrderAddressMapper;
import com.sckw.transport.model.KwtWaybillOrderAddress;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;


/**
 * @author PC
 */
@Repository
public class KwtWaybillOrderAddressRepository extends ServiceImpl<KwtWaybillOrderAddressMapper, KwtWaybillOrderAddress> {
    public List<KwtWaybillOrderAddress> queryByWOrderId(Long wOrderId) {

        return list(Wrappers.<KwtWaybillOrderAddress>lambdaQuery()
                .eq(KwtWaybillOrderAddress::getWOrderId, wOrderId)
                .eq(KwtWaybillOrderAddress::getDelFlag, 0));
    }

    public List<KwtWaybillOrderAddress> queryBywOrderIds(List<Long> wOrderIds) {
        return list(Wrappers.<KwtWaybillOrderAddress>lambdaQuery()
                .eq(KwtWaybillOrderAddress::getDelFlag, 0)
                .in(KwtWaybillOrderAddress::getWOrderId, wOrderIds));
    }

    public List<KwtWaybillOrderAddress> queryBySubBillOrderId(Set<Long> subWayBillOrderIds) {
        return list(Wrappers.<KwtWaybillOrderAddress>lambdaQuery()
                .eq(KwtWaybillOrderAddress::getDelFlag, 0)
                .in(KwtWaybillOrderAddress::getWSubtaskId, subWayBillOrderIds));
    }

    public KwtWaybillOrderAddress queryByBillOrderIdAndType(Long wOrderId, Integer type) {
        return getOne(Wrappers.<KwtWaybillOrderAddress>lambdaQuery()
                .eq(KwtWaybillOrderAddress::getWOrderId, wOrderId)
                .eq(KwtWaybillOrderAddress::getAddressType, type)
                .eq(KwtWaybillOrderAddress::getDelFlag,0));
    }
}
