<?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.system.mapper.ClewVideoMapper">

    <resultMap type="ClewVideo" id="ClewVideoResult">
        <result property="id"    column="id"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="videoImg"    column="video_img"    />
        <result property="videoTitle"    column="video_title"    />
        <result property="videoShowDate"    column="video_show_date"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectClewVideoVo">
        select id, video_url, video_img, video_title, video_show_date, create_time, create_by, update_time, update_by, remark from clew_video
    </sql>

    <select id="selectClewVideoList" parameterType="ClewVideo" resultMap="ClewVideoResult">
        <include refid="selectClewVideoVo"/>
        <where>
            <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
            <if test="videoTitle != null  and videoTitle != ''"> and video_title = #{videoTitle}</if>
            <if test="videoShowDate != null  and videoShowDate != ''"> and video_show_date = #{videoShowDate}</if>
        </where>
    </select>

    <select id="selectClewVideoById" parameterType="Long" resultMap="ClewVideoResult">
        <include refid="selectClewVideoVo"/>
        where id = #{id}
    </select>

    <insert id="insertClewVideo" parameterType="ClewVideo" useGeneratedKeys="true" keyProperty="id">
        insert into clew_video
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="videoUrl != null">video_url,</if>
            <if test="videoImg != null">video_img,</if>
            <if test="videoTitle != null">video_title,</if>
            <if test="videoShowDate != null">video_show_date,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="videoUrl != null">#{videoUrl},</if>
            <if test="videoImg != null">#{videoImg},</if>
            <if test="videoTitle != null">#{videoTitle},</if>
            <if test="videoShowDate != null">#{videoShowDate},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateClewVideo" parameterType="ClewVideo">
        update clew_video
        <trim prefix="SET" suffixOverrides=",">
            <if test="videoUrl != null">video_url = #{videoUrl},</if>
            <if test="videoImg != null">video_img = #{videoImg},</if>
            <if test="videoTitle != null">video_title = #{videoTitle},</if>
            <if test="videoShowDate != null">video_show_date = #{videoShowDate},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteClewVideoById" parameterType="Long">
        delete from clew_video where id = #{id}
    </delete>

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

</mapper>