package com.sckw.transport.repository;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sckw.core.model.base.BaseModel;
import com.sckw.transport.dao.KwtWaybillOrderSubtaskMapper;
import com.sckw.transport.model.KwtWaybillOrderSubtask;
import org.springframework.stereotype.Repository;

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

/**
 * @author PC
 */
@Repository
public class KwtWaybillOrderSubtaskRepository extends ServiceImpl<KwtWaybillOrderSubtaskMapper, KwtWaybillOrderSubtask> {
    public KwtWaybillOrderSubtask findOneByWOrderNo(String wOrderNo) {
       return getOne(Wrappers.<KwtWaybillOrderSubtask>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwtWaybillOrderSubtask::getWOrderNo,wOrderNo)
                .orderByDesc(KwtWaybillOrderSubtask::getId)
                 .last("limit 1"));
    }

    public List<KwtWaybillOrderSubtask> findOneByWOrderIds(Set<Long> wOrderIds) {
        return list(Wrappers.<KwtWaybillOrderSubtask>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwtWaybillOrderSubtask::getWOrderId,wOrderIds));
    }

    public List<KwtWaybillOrderSubtask> findByEntId(Long entId) {
        return list(Wrappers.<KwtWaybillOrderSubtask>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwtWaybillOrderSubtask::getEntId,entId));
    }

    public List<KwtWaybillOrderSubtask> queryByWOrderIds(List<Long> wOrderIds) {

        return list(Wrappers.<KwtWaybillOrderSubtask>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwtWaybillOrderSubtask::getWOrderId,wOrderIds));
    }
}
