<?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.course.mapper.FsUserVideoMapper">

    <resultMap type="FsUserVideo" id="FsUserVideoResult">
        <result property="videoId"    column="video_id"    />
        <result property="fileId"    column="file_id"    />
        <result property="title"    column="title"    />
        <result property="description"    column="description"    />
        <result property="url"    column="url"    />
        <result property="thumbnail"    column="thumbnail"    />
        <result property="duration"    column="duration"    />
        <result property="createTime"    column="create_time"    />
        <result property="talentId"    column="talent_id"    />
        <result property="cateId"    column="cate_id"    />
        <result property="likes"    column="likes"    />
        <result property="views"    column="views"    />
        <result property="comments"    column="comments"    />
        <result property="status"    column="status"    />
        <result property="isHot"    column="is_hot"    />
        <result property="isAudit"    column="is_audit"    />
        <result property="auditBy"    column="audit_by"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="source"    column="source"    />
        <result property="isDel"    column="is_del"    />
        <result property="shares"    column="shares"    />
        <result property="tags"    column="tags"    />
        <result property="productId"    column="product_id"    />
        <result property="productJson"    column="product_json"    />
        <result property="favoriteNum"    column="favorite_num"    />
        <result property="uploadType"    column="upload_type"    />
        <result property="txCdnUrl"    column="tx_cdn_url"    />
        <result property="txPcdnUrl"    column="tx_pcdn_url"    />
        <result property="txVodUrl"    column="tx_vod_url"    />
        <result property="hwObsUrl"    column="hw_obs_url"    />
        <result property="hwVodUrl"    column="hw_vod_url"    />
    </resultMap>

    <sql id="selectFsUserVideoVo">
        select video_id, file_id, title, description, url, thumbnail, duration, create_time, talent_id, cate_id, likes, views, comments, status, is_hot, is_audit, audit_by, audit_time, update_time, source, is_del, shares, tags, product_id, product_json, favorite_num, upload_type, tx_cdn_url, tx_pcdn_url, tx_vod_url, hw_obs_url, hw_vod_url from fs_user_video
    </sql>

    <select id="selectFsUserVideoList" parameterType="FsUserVideo" resultMap="FsUserVideoResult">
        <include refid="selectFsUserVideoVo"/>
        <where>
            is_del = 0
            <if test="fileId != null  and fileId != ''"> and file_id = #{fileId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="thumbnail != null  and thumbnail != ''"> and thumbnail = #{thumbnail}</if>
            <if test="duration != null "> and duration = #{duration}</if>
            <if test="talentId != null "> and talent_id = #{talentId}</if>
            <if test="cateId != null "> and cate_id = #{cateId}</if>
            <if test="likes != null "> and likes = #{likes}</if>
            <if test="views != null "> and views = #{views}</if>
            <if test="comments != null "> and comments = #{comments}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="isHot != null "> and is_hot = #{isHot}</if>
            <if test="isAudit != null "> and is_audit = #{isAudit}</if>
            <if test="auditBy != null "> and audit_by = #{auditBy}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="source != null "> and source = #{source}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="shares != null "> and shares = #{shares}</if>
            <if test="tags != null  and tags != ''"> and tags = #{tags}</if>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="productJson != null  and productJson != ''"> and product_json = #{productJson}</if>
            <if test="favoriteNum != null "> and favorite_num = #{favoriteNum}</if>
        </where>
    </select>

    <select id="selectFsUserVideoByVideoId" parameterType="String" resultMap="FsUserVideoResult">
        <include refid="selectFsUserVideoVo"/>
        where video_id = #{videoId}
    </select>

    <insert id="insertFsUserVideo" parameterType="FsUserVideo" useGeneratedKeys="true" keyProperty="videoId">
        insert into fs_user_video
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileId != null">file_id,</if>
            <if test="title != null">title,</if>
            <if test="description != null">description,</if>
            <if test="url != null">url,</if>
            <if test="thumbnail != null">thumbnail,</if>
            <if test="duration != null">duration,</if>
            <if test="createTime != null">create_time,</if>
            <if test="talentId != null">talent_id,</if>
            <if test="cateId != null">cate_id,</if>
            <if test="likes != null">likes,</if>
            <if test="views != null">views,</if>
            <if test="comments != null">comments,</if>
            <if test="status != null">status,</if>
            <if test="isHot != null">is_hot,</if>
            <if test="isAudit != null">is_audit,</if>
            <if test="auditBy != null">audit_by,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="source != null">source,</if>
            <if test="isDel != null">is_del,</if>
            <if test="shares != null">shares,</if>
            <if test="tags != null">tags,</if>
            <if test="productId != null">product_id,</if>
            <if test="productJson != null">product_json,</if>
            <if test="favoriteNum != null">favorite_num,</if>
            <if test="uploadType != null">upload_type,</if>
            <if test="txCdnUrl != null">tx_cdn_url,</if>
            <if test="txPcdnUrl != null">tx_pcdn_url,</if>
            <if test="txVodUrl != null">tx_vod_url,</if>
            <if test="hwObsUrl != null">hw_obs_url,</if>
            <if test="hwVodUrl != null">hw_vod_url,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileId != null">#{fileId},</if>
            <if test="title != null">#{title},</if>
            <if test="description != null">#{description},</if>
            <if test="url != null">#{url},</if>
            <if test="thumbnail != null">#{thumbnail},</if>
            <if test="duration != null">#{duration},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="talentId != null">#{talentId},</if>
            <if test="cateId != null">#{cateId},</if>
            <if test="likes != null">#{likes},</if>
            <if test="views != null">#{views},</if>
            <if test="comments != null">#{comments},</if>
            <if test="status != null">#{status},</if>
            <if test="isHot != null">#{isHot},</if>
            <if test="isAudit != null">#{isAudit},</if>
            <if test="auditBy != null">#{auditBy},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="source != null">#{source},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="shares != null">#{shares},</if>
            <if test="tags != null">#{tags},</if>
            <if test="productId != null">#{productId},</if>
            <if test="productJson != null">#{productJson},</if>
            <if test="favoriteNum != null">#{favoriteNum},</if>
            <if test="uploadType != null">#{uploadType},</if>
            <if test="txCdnUrl != null">#{txCdnUrl},</if>
            <if test="txPcdnUrl != null">#{txPcdnUrl},</if>
            <if test="txVodUrl != null">#{txVodUrl},</if>
            <if test="hwObsUrl != null">#{hwObsUrl},</if>
            <if test="hwVodUrl != null">#{hwVodUrl},</if>
        </trim>
    </insert>

    <update id="updateFsUserVideo" parameterType="FsUserVideo">
        update fs_user_video
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileId != null">file_id = #{fileId},</if>
            <if test="title != null">title = #{title},</if>
            <if test="description != null">description = #{description},</if>
            <if test="url != null">url = #{url},</if>
            <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
            <if test="duration != null">duration = #{duration},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="talentId != null">talent_id = #{talentId},</if>
            <if test="cateId != null">cate_id = #{cateId},</if>
            <if test="likes != null">likes = #{likes},</if>
            <if test="views != null">views = #{views},</if>
            <if test="comments != null">comments = #{comments},</if>
            <if test="status != null">status = #{status},</if>
            <if test="isHot != null">is_hot = #{isHot},</if>
            <if test="isAudit != null">is_audit = #{isAudit},</if>
            <if test="auditBy != null">audit_by = #{auditBy},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="source != null">source = #{source},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="shares != null">shares = #{shares},</if>
            <if test="tags != null">tags = #{tags},</if>
            <if test="productId != null">product_id = #{productId},</if>
            <if test="productJson != null">product_json = #{productJson},</if>
            <if test="favoriteNum != null">favorite_num = #{favoriteNum},</if>
            <if test="uploadType != null">upload_type = #{uploadType},</if>
            <if test="txCdnUrl != null">tx_cdn_url = #{txCdnUrl},</if>
            <if test="txPcdnUrl != null">tx_pcdn_url = #{txPcdnUrl},</if>
            <if test="txVodUrl != null">tx_vod_url = #{txVodUrl},</if>
            <if test="hwObsUrl != null">hw_obs_url = #{hwObsUrl},</if>
            <if test="hwVodUrl != null">hw_vod_url = #{hwVodUrl},</if>
        </trim>
        where video_id = #{videoId}
    </update>

    <update id="deleteFsUserVideoByVideoId" parameterType="String">
        update fs_user_video set is_del = 1 where video_id = #{videoId}
    </update>

    <update id="deleteFsUserVideoByVideoIds" parameterType="String">
        update fs_user_video set is_del = 1 where video_id in
        <foreach item="videoId" collection="array" open="(" separator="," close=")">
            #{videoId}
        </foreach>
    </update>
</mapper>
