<?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.tuya.mapper.BusTravelExperienceMapper">

    <resultMap type="BusTravelExperience" id="BusTravelExperienceResult">
        <result property="uuid"    column="uuid"    />
        <result property="dayNum"    column="day_num"    />
        <result property="synopsis"    column="synopsis"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
    </resultMap>

    <sql id="selectBusTravelExperienceVo">
        select a.uuid, a.day_num, a.synopsis, a.video_url, a.img_url, a.id, a.title
        from bus_travel_experience a inner join bus_travel b on a.uuid = b.uuid
    </sql>

    <select id="selectBusTravelExperienceList" parameterType="BusTravelExperience" resultMap="BusTravelExperienceResult">
        <include refid="selectBusTravelExperienceVo"/>
        <where>
            <if test="uuid != null  and uuid != ''"> and a.uuid = #{uuid}</if>
            <if test="dayNum != null  and dayNum != ''"> and a.day_num = #{dayNum}</if>
            <if test="synopsis != null  and synopsis != ''"> and a.synopsis = #{synopsis}</if>
            <if test="videoUrl != null  and videoUrl != ''"> and a.video_url = #{videoUrl}</if>
            <if test="imgUrl != null  and imgUrl != ''"> and a.img_url = #{imgUrl}</if>
            <if test="title != null  and title != ''"> and a.title like concat('%', #{title}, '%')</if>
        </where>
    </select>

    <select id="selectBusTravelExperienceById" parameterType="Long" resultMap="BusTravelExperienceResult">
        <include refid="selectBusTravelExperienceVo"/>
        where a.id = #{id}
    </select>

    <insert id="insertBusTravelExperience" parameterType="BusTravelExperience">
        insert into bus_travel_experience
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="uuid != null">uuid,</if>
            <if test="dayNum != null">day_num,</if>
            <if test="synopsis != null">synopsis,</if>
            <if test="videoUrl != null">video_url,</if>
            <if test="imgUrl != null">img_url,</if>
            <if test="id != null">id,</if>
            <if test="title != null">title,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="uuid != null">#{uuid},</if>
            <if test="dayNum != null">#{dayNum},</if>
            <if test="synopsis != null">#{synopsis},</if>
            <if test="videoUrl != null">#{videoUrl},</if>
            <if test="imgUrl != null">#{imgUrl},</if>
            <if test="id != null">#{id},</if>
            <if test="title != null">#{title},</if>
         </trim>
    </insert>

    <update id="updateBusTravelExperience" parameterType="BusTravelExperience">
        update bus_travel_experience
        <trim prefix="SET" suffixOverrides=",">
            <if test="uuid != null">uuid = #{uuid},</if>
            <if test="dayNum != null">day_num = #{dayNum},</if>
            <if test="synopsis != null">synopsis = #{synopsis},</if>
            <if test="videoUrl != null">video_url = #{videoUrl},</if>
            <if test="imgUrl != null">img_url = #{imgUrl},</if>
            <if test="title != null">title = #{title},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusTravelExperienceById" parameterType="Long">
        delete from bus_travel_experience where id = #{id}
    </delete>

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