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

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

/**
 * @author PC
 * 司机信息接口
 */
@Repository
public class KwfDriverRepository extends ServiceImpl<KwfDriverMapper, KwfDriver> {
    public KwfDriver queryOneByPhone(String mobile) {
        return getOne(Wrappers.<KwfDriver>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwfDriver::getPhone,mobile)
                .last("limit 1"));
    }

    public List<KwfDriver> findDriverByName(String driverName) {
        return list(Wrappers.<KwfDriver>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .like(KwfDriver::getName,driverName));
    }

    public List<KwfDriver> findByDriverIds(Set<Long> driveIdList) {
        return list(Wrappers.<KwfDriver>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwfDriver::getId,driveIdList));
    }

}
