<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.muyu.enterprise.mapper.car.VehicleMapper">

    <select id="findAll" resultType="com.muyu.enterprise.domain.resp.car.VehicleManageResp">
        SELECT
            v.vehicle_id,
            v.licence_number,
            v.vehicle_color,
            v.vehicle_vin,
            v.vehicle_brand,
            v.vehicle_model,
            v.vehicle_license_due_date,
            v.vehicle_status,
            t.vehicle_type_name
        FROM
            vehicle v
                LEFT JOIN vehicle_type t ON v.vehicle_type_id = t.vehicle_type_id
        <where>
            <if test="null != licenceNumber and '' != licenceNumber">
                and v.licence_number like '%${licenceNumber}%'
            </if>
            <if test="null != vehicleVin and '' != vehicleVin">
                and v.vehicle_vin like '%${vehicleVin}%'
            </if>
            <if test="null != vehicleStatus and '' != vehicleStatus">
                and v.vehicle_status = #{vehicleStatus}
            </if>
        </where>
    </select>
</mapper>
