<?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.fs.qw.mapper.QwUserVideoMapper">

    <resultMap type="QwUserVideo" id="QwUserVideoResult">
        <result property="id"    column="id"    />
        <result property="appKey"    column="app_key"    />
        <result property="senderName"    column="sender_name"    />
        <result property="objectId"    column="object_id"    />
        <result property="coverUrl"    column="cover_url"    />
        <result property="thumbUrl"    column="thumb_url"    />
        <result property="avatar"    column="avatar"    />
        <result property="nickName"    column="nick_name"    />
        <result property="desc"    column="desc"    />
        <result property="url"    column="url"    />
        <result property="extras"    column="extras"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectQwUserVideoVo">
        select id, app_key, sender_name, object_id, cover_url, thumb_url, avatar, nick_name, `desc`, url, extras,update_time,create_time from qw_user_video
    </sql>

    <select id="selectQwUserVideoList" parameterType="QwUserVideo" resultMap="QwUserVideoResult">
        <include refid="selectQwUserVideoVo"/>
        <where>
            <if test="appKey != null "> and app_key = #{appKey}</if>
            <if test="senderName != null  and senderName != ''"> and sender_name like concat('%', #{senderName}, '%')</if>
            <if test="objectId != null "> and object_id = #{objectId}</if>
            <if test="coverUrl != null  and coverUrl != ''"> and cover_url = #{coverUrl}</if>
            <if test="thumbUrl != null  and thumbUrl != ''"> and thumb_url = #{thumbUrl}</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="desc != null  and desc != ''"> and `desc` = #{desc}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="extras != null  and extras != ''"> and extras = #{extras}</if>
            <if test="updateTime != null  and updateTime != ''"> and update_time = #{updateTime}</if>
            <if test="createTime != null  and createTime != ''"> and create_time = #{createTime}</if>
        </where>
    </select>

    <select id="selectQwUserVideoById" parameterType="Long" resultMap="QwUserVideoResult">
        <include refid="selectQwUserVideoVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwUserVideo" parameterType="QwUserVideo">
        insert into qw_user_video
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="appKey != null">app_key,</if>
            <if test="senderName != null">sender_name,</if>
            <if test="objectId != null">object_id,</if>
            <if test="coverUrl != null">cover_url,</if>
            <if test="thumbUrl != null">thumb_url,</if>
            <if test="avatar != null">avatar,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="desc != null">`desc`,</if>
            <if test="url != null">url,</if>
            <if test="extras != null">extras,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="appKey != null">#{appKey},</if>
            <if test="senderName != null">#{senderName},</if>
            <if test="objectId != null">#{objectId},</if>
            <if test="coverUrl != null">#{coverUrl},</if>
            <if test="thumbUrl != null">#{thumbUrl},</if>
            <if test="avatar != null">#{avatar},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="desc != null">#{desc},</if>
            <if test="url != null">#{url},</if>
            <if test="extras != null">#{extras},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateQwUserVideo" parameterType="QwUserVideo">
        update qw_user_video
        <trim prefix="SET" suffixOverrides=",">
            <if test="appKey != null">app_key = #{appKey},</if>
            <if test="senderName != null">sender_name = #{senderName},</if>
            <if test="objectId != null">object_id = #{objectId},</if>
            <if test="coverUrl != null">cover_url = #{coverUrl},</if>
            <if test="thumbUrl != null">thumb_url = #{thumbUrl},</if>
            <if test="avatar != null">avatar = #{avatar},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="desc != null">`desc` = #{desc},</if>
            <if test="url != null">url = #{url},</if>
            <if test="extras != null">extras = #{extras},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwUserVideoById" parameterType="Long">
        delete from qw_user_video where id = #{id}
    </delete>

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