package com.sckw.fleet.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.fleet.dao.KwfFleetTruckMapper;
import com.sckw.fleet.model.KwfFleetTruck;
import org.springframework.stereotype.Repository;

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


/**
 * @author PC
 * 车队-车辆接口
 */
@Repository
public class KwfFleetTruckRepository extends ServiceImpl<KwfFleetTruckMapper, KwfFleetTruck> {
    public List<KwfFleetTruck> queryByFleetIds(Set<Long> fleetIds) {

        return list(Wrappers.<KwfFleetTruck>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwfFleetTruck::getFleetId,fleetIds));
    }

    public List<KwfFleetTruck> queryByTruckId(Long truckId) {
        return list(Wrappers.<KwfFleetTruck>lambdaQuery()
                .eq(BaseModel::getDelFlag,0).
                eq(KwfFleetTruck::getTruckId, truckId));
    }

    public List<KwfFleetTruck> queryByTruckIds(Set<Long> truckIds) {
        return list(Wrappers.<KwfFleetTruck>lambdaQuery()
                .eq(BaseModel::getDelFlag,0).
                in(KwfFleetTruck::getTruckId, truckIds));
    }

    public KwfFleetTruck findFleetByTruckId(Long truckId) {
        return getOne(Wrappers.<KwfFleetTruck>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwfFleetTruck::getTruckId, truckId)
                .orderByDesc(BaseModel::getId)
                .last("limit 1"));
    }
}
