package com.xindazhou.vehicle.dal.mysql.vehicle;

import com.xindazhou.framework.mybatis.core.mapper.BaseMapperX;
import com.xindazhou.vehicle.dal.dataobject.vehicle.VehicleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 车辆 Mapper
 *
 * @author xindazhou
 */
@Mapper
public interface VehicleMapper extends BaseMapperX<VehicleDO> {

    /**
     * 根据VIN查询车辆
     *
     * @param vin 车架号
     * @return 车辆
     */
    default VehicleDO selectByVin(String vin) {
        return selectOne(VehicleDO::getVin, vin, VehicleDO::getDeleted, false);
    }

    /**
     * 根据设备序列号查询车辆
     *
     * @param deviceSn 设备序列号
     * @return 车辆
     */
    default VehicleDO selectByDeviceSn(String deviceSn) {
        return selectOne(VehicleDO::getDeviceSn, deviceSn, VehicleDO::getDeleted, false);
    }

    /**
     * 根据蓝牙MAC地址查询车辆
     *
     * @param bluetoothMac 蓝牙MAC地址
     * @return 车辆
     */
    default VehicleDO selectByBluetoothMac(String bluetoothMac) {
        return selectOne(VehicleDO::getBluetoothMac, bluetoothMac, VehicleDO::getDeleted, false);
    }

}

