<?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.VehiclePhotoMapper">
    
    <resultMap type="VehiclePhoto" id="VehiclePhotoResult">
        <result property="id"    column="id"    />
        <result property="vehicleId"    column="vehicle_id"    />
        <result property="type"    column="type"    />
        <result property="url"    column="url"    />
        <result property="creationDate"    column="creation_date"    />
        <result property="delFlag"    column="del_flag"    />
    </resultMap>

    <sql id="selectVehiclePhotoVo">
        select id, vehicle_id, type, url, creation_date, del_flag from vehicle_photo
    </sql>

    <select id="selectVehiclePhotoList" parameterType="VehiclePhoto" resultMap="VehiclePhotoResult">
        <include refid="selectVehiclePhotoVo"/>
        <where>  
            <if test="vehicleId != null "> and vehicle_id = #{vehicleId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="creationDate != null "> and creation_date = #{creationDate}</if>
            <if test="delFlag != null "> and del_flag = #{delFlag}</if>
        </where>
    </select>
    
    <select id="selectVehiclePhotoById" parameterType="Long" resultMap="VehiclePhotoResult">
        <include refid="selectVehiclePhotoVo"/>
        where id = #{id}
    </select>

    <insert id="insertVehiclePhoto" parameterType="VehiclePhoto" useGeneratedKeys="true" keyProperty="id">
        insert into vehicle_photo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="vehicleId != null">vehicle_id,</if>
            <if test="type != null">type,</if>
            <if test="url != null">url,</if>
            <if test="creationDate != null">creation_date,</if>
            <if test="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="vehicleId != null">#{vehicleId},</if>
            <if test="type != null">#{type},</if>
            <if test="url != null">#{url},</if>
            <if test="creationDate != null">#{creationDate},</if>
            <if test="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateVehiclePhoto" parameterType="VehiclePhoto">
        update vehicle_photo
        <trim prefix="SET" suffixOverrides=",">
            <if test="vehicleId != null">vehicle_id = #{vehicleId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="url != null">url = #{url},</if>
            <if test="creationDate != null">creation_date = #{creationDate},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVehiclePhotoById" parameterType="Long">
        delete from vehicle_photo where id = #{id}
    </delete>

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