<?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.maintain.business.mapper.ErpCarMapper">

    <resultMap type="com.maintain.business.domain.ErpCar" id="ErpCarResult">
        <result property="id" column="id"/>
        <result property="plateNumber" column="plate_number"/>
        <result property="phone" column="phone"/>
        <result property="clientId" column="client_id"/>
        <result property="clientName" column="client_name"/>
        <result property="carVin" column="car_vin"/>
        <result property="drivingLicenseUrl" column="driving_license_url"/>
        <result property="carImgUrl" column="car_img_url"/>
        <result property="carTypeId" column="car_type_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column=" create_time"/>
    </resultMap>

    <resultMap type="com.maintain.business.domain.vo.ErpCarVo" id="ErpCarVoResult">
        <result property="id" column="id"/>
        <result property="plateNumber" column="plate_number"/>
        <result property="carBrand" column="car_brand"/>
        <result property="carModel" column="car_model"/>
        <result property="clientType" column="type"/>
        <result property="clientContact" column="contact"/>
        <result property="phone" column="phone"/>
        <result property="clientId" column="client_id"/>
        <result property="clientName" column="client_name"/>
        <result property="carVin" column="car_vin"/>
        <result property="drivingLicenseUrl" column="driving_license_url"/>
        <result property="carImgUrl" column="car_img_url"/>
        <result property="carTypeId" column="car_type_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <select id="selectPageCarList" parameterType="com.maintain.business.domain.vo.ErpCarVo" resultMap="ErpCarVoResult">
         select t.id, t.plate_number, t.phone, t.client_id, t.client_name, t.car_vin, t2.car_type_code, t2.car_brand,
               t2.car_model, t1.type,t.driving_license_url, t.car_img_url, t.car_type_id, t.create_by, t.create_time
         from erp_car t
         left join erp_client t1 on t.client_id = t1.id
         left join erp_vehicle_model t2 on t.car_type_id = t2.id
         ${ew.getCustomSqlSegment}
    </select>

    <select id="selectCarList" parameterType="com.maintain.business.domain.vo.ErpCarVo" resultMap="ErpCarVoResult">
         select t.id, t.plate_number, t.phone, t.client_id, t.client_name, t.car_vin, t2.car_type_code, t2.car_brand,
               t2.car_model, t1.type,t.driving_license_url, t.car_img_url, t.car_type_id, t.create_by, t.create_time
         from erp_car t
         left join erp_client t1 on t.client_id = t1.id
         left join erp_vehicle_model t2 on t.car_type_id = t2.id
         ${ew.getCustomSqlSegment}
    </select>

</mapper>
