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.KwfTruckEntMapper;
import com.sckw.fleet.model.KwfTruckEnt;
import org.springframework.stereotype.Repository;

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

/**
 * @author PC
 * 车辆信息与企业关联信息接口
 */
@Repository
public class KwfTruckEntRepository extends ServiceImpl<KwfTruckEntMapper, KwfTruckEnt> {
    public List<KwfTruckEnt> findTruckEntByEntIds(Long entId) {
        return list(Wrappers.<KwfTruckEnt>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwfTruckEnt::getEntId,entId)
                .orderByDesc(BaseModel::getCreateTime));
    }

    public List<KwfTruckEnt> findTruckEntByEntIds(Set<Long> entId) {
        return list(Wrappers.<KwfTruckEnt>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwfTruckEnt::getEntId,entId)
                .orderByDesc(BaseModel::getCreateTime));
    }

    public List<KwfTruckEnt> findTruckEntByEntIdAndTruckId(Long entId, Long truckId) {
        return list(Wrappers.<KwfTruckEnt>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwfTruckEnt::getEntId,entId)
                .eq(KwfTruckEnt::getTruckId ,truckId)
                .orderByDesc(BaseModel::getCreateTime));
    }
}
