<?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.ruoyi.custclient.mapper.VehicleInfoMapper">
    
    <resultMap type="VehicleInfo" id="VehicleInfoResult">
        <result property="id"    column="id"    />
        <result property="custId"    column="cust_id"    />
        <result property="licenseNo"    column="license_no"    />
        <result property="vinNo"    column="vin_no"    />
        <result property="brandName"    column="brand_name"    />
        <result property="engineNo"    column="engine_no"    />
        <result property="caryear"    column="caryear"    />
        <result property="seatCount"    column="seat_count"    />
        <result property="completeKerbMass"    column="complete_kerb_mass"    />
        <result property="limitLoad"    column="limit_load"    />
        <result property="engineDesc"    column="engine_desc"    />
        <result property="powerScale"    column="power_scale"    />
        <result property="purchasePrice"    column="purchase_price"    />
        <result property="property"    column="property"    />
        <result property="vehicleUse"    column="vehicle_use"    />
        <result property="cartype"    column="cartype"    />
        <result property="cimodelclass"    column="cimodelclass"    />
        <result property="energyType"    column="energy_type"    />
        <result property="registerDate"    column="register_date"    />
        <result property="issueDate"    column="issue_date"    />
        <result property="noLicenseFlag"    column="no_license_flag"    />
    </resultMap>

    <sql id="selectVehicleInfoVo">
        select id, cust_id, license_no, vin_no, brand_name, engine_no, caryear, seat_count, complete_kerb_mass, limit_load, engine_desc, power_scale, purchase_price, property, vehicle_use, cartype, cimodelclass, energy_type, register_date, issue_date, no_license_flag from vehicle_info
    </sql>

    <select id="selectVehicleInfoList" parameterType="VehicleInfo" resultMap="VehicleInfoResult">
        <include refid="selectVehicleInfoVo"/>
        <where>  
            <if test="custId != null "> and cust_id = #{custId}</if>
            <if test="licenseNo != null  and licenseNo != ''"> and license_no like concat('%', #{licenseNo}, '%')</if>
            <if test="vinNo != null  and vinNo != ''"> and vin_no like concat('%', #{vinNo}, '%')</if>
            <if test="brandName != null  and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
            <if test="engineNo != null  and engineNo != ''"> and engine_no like concat('%', #{engineNo}, '%')</if>
            <if test="caryear != null  and caryear != ''"> and caryear = #{caryear}</if>
            <if test="seatCount != null "> and seat_count = #{seatCount}</if>
            <if test="completeKerbMass != null "> and complete_kerb_mass = #{completeKerbMass}</if>
            <if test="limitLoad != null "> and limit_load = #{limitLoad}</if>
            <if test="engineDesc != null "> and engine_desc = #{engineDesc}</if>
            <if test="powerScale != null "> and power_scale = #{powerScale}</if>
            <if test="purchasePrice != null "> and purchase_price = #{purchasePrice}</if>
            <if test="property != null  and property != ''"> and property = #{property}</if>
            <if test="vehicleUse != null "> and vehicle_use = #{vehicleUse}</if>
            <if test="cartype != null  and cartype != ''"> and cartype = #{cartype}</if>
            <if test="cimodelclass != null  and cimodelclass != ''"> and cimodelclass = #{cimodelclass}</if>
            <if test="energyType != null "> and energy_type = #{energyType}</if>
            <if test="registerDate != null "> and register_date = #{registerDate}</if>
            <if test="issueDate != null "> and issue_date = #{issueDate}</if>
            <if test="noLicenseFlag != null "> and no_license_flag = #{noLicenseFlag}</if>
        </where>
    </select>
    
    <select id="selectVehicleInfoById" parameterType="Long" resultMap="VehicleInfoResult">
        <include refid="selectVehicleInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertVehicleInfo" parameterType="VehicleInfo" useGeneratedKeys="true" keyProperty="id">
        insert into vehicle_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="custId != null">cust_id,</if>
            <if test="licenseNo != null">license_no,</if>
            <if test="vinNo != null and vinNo != ''">vin_no,</if>
            <if test="brandName != null and brandName != ''">brand_name,</if>
            <if test="engineNo != null and engineNo != ''">engine_no,</if>
            <if test="caryear != null">caryear,</if>
            <if test="seatCount != null">seat_count,</if>
            <if test="completeKerbMass != null">complete_kerb_mass,</if>
            <if test="limitLoad != null">limit_load,</if>
            <if test="engineDesc != null">engine_desc,</if>
            <if test="powerScale != null">power_scale,</if>
            <if test="purchasePrice != null">purchase_price,</if>
            <if test="property != null">property,</if>
            <if test="vehicleUse != null">vehicle_use,</if>
            <if test="cartype != null">cartype,</if>
            <if test="cimodelclass != null and cimodelclass != ''">cimodelclass,</if>
            <if test="energyType != null">energy_type,</if>
            <if test="registerDate != null">register_date,</if>
            <if test="issueDate != null">issue_date,</if>
            <if test="noLicenseFlag != null">no_license_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="custId != null">#{custId},</if>
            <if test="licenseNo != null">#{licenseNo},</if>
            <if test="vinNo != null and vinNo != ''">#{vinNo},</if>
            <if test="brandName != null and brandName != ''">#{brandName},</if>
            <if test="engineNo != null and engineNo != ''">#{engineNo},</if>
            <if test="caryear != null">#{caryear},</if>
            <if test="seatCount != null">#{seatCount},</if>
            <if test="completeKerbMass != null">#{completeKerbMass},</if>
            <if test="limitLoad != null">#{limitLoad},</if>
            <if test="engineDesc != null">#{engineDesc},</if>
            <if test="powerScale != null">#{powerScale},</if>
            <if test="purchasePrice != null">#{purchasePrice},</if>
            <if test="property != null">#{property},</if>
            <if test="vehicleUse != null">#{vehicleUse},</if>
            <if test="cartype != null">#{cartype},</if>
            <if test="cimodelclass != null and cimodelclass != ''">#{cimodelclass},</if>
            <if test="energyType != null">#{energyType},</if>
            <if test="registerDate != null">#{registerDate},</if>
            <if test="issueDate != null">#{issueDate},</if>
            <if test="noLicenseFlag != null">#{noLicenseFlag},</if>
         </trim>
    </insert>

    <update id="updateVehicleInfo" parameterType="VehicleInfo">
        update vehicle_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="custId != null">cust_id = #{custId},</if>
            <if test="licenseNo != null">license_no = #{licenseNo},</if>
            <if test="vinNo != null and vinNo != ''">vin_no = #{vinNo},</if>
            <if test="brandName != null and brandName != ''">brand_name = #{brandName},</if>
            <if test="engineNo != null and engineNo != ''">engine_no = #{engineNo},</if>
            <if test="caryear != null">caryear = #{caryear},</if>
            <if test="seatCount != null">seat_count = #{seatCount},</if>
            <if test="completeKerbMass != null">complete_kerb_mass = #{completeKerbMass},</if>
            <if test="limitLoad != null">limit_load = #{limitLoad},</if>
            <if test="engineDesc != null">engine_desc = #{engineDesc},</if>
            <if test="powerScale != null">power_scale = #{powerScale},</if>
            <if test="purchasePrice != null">purchase_price = #{purchasePrice},</if>
            <if test="property != null">property = #{property},</if>
            <if test="vehicleUse != null">vehicle_use = #{vehicleUse},</if>
            <if test="cartype != null">cartype = #{cartype},</if>
            <if test="cimodelclass != null and cimodelclass != ''">cimodelclass = #{cimodelclass},</if>
            <if test="energyType != null">energy_type = #{energyType},</if>
            <if test="registerDate != null">register_date = #{registerDate},</if>
            <if test="issueDate != null">issue_date = #{issueDate},</if>
            <if test="noLicenseFlag != null">no_license_flag = #{noLicenseFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVehicleInfoById" parameterType="Long">
        delete from vehicle_info where id = #{id}
    </delete>

    <delete id="deleteVehicleInfoByIds" parameterType="String">
        delete from vehicle_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>