<?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.abuwx.mapper.VideoContentMapper">
    
    <resultMap type="VideoContent" id="VideoContentResult">
        <result property="id"    column="id"    />
        <result property="categoryId"    column="category_id"    />
        <result property="title"    column="title"    />
        <result property="picPath"    column="pic_path"    />
        <result property="status"    column="status"    />
        <result property="publishTime"    column="publish_time"    />
        <result property="cancelTime"    column="cancel_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
        <result property="videoPath"    column="video_path"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="checkResult"    column="check_result"    />
        <result property="publishStatus"    column="publish_status"    />
    </resultMap>

    <sql id="selectVideoContentVo">
        select id, category_id, title, pic_path, status, publish_time, cancel_time, create_time, update_time, create_by, update_by, remark, video_path, check_status, check_result, publish_status from video_content
    </sql>

    <select id="selectVideoContentList" parameterType="VideoContent" resultMap="VideoContentResult">
        <include refid="selectVideoContentVo"/>
        <where>  
            <if test="categoryId != null "> and category_id = #{categoryId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="picPath != null  and picPath != ''"> and pic_path = #{picPath}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
            <if test="cancelTime != null "> and cancel_time = #{cancelTime}</if>
            <if test="videoPath != null  and videoPath != ''"> and video_path = #{videoPath}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
            <if test="checkResult != null  and checkResult != ''"> and check_result = #{checkResult}</if>
            <if test="publishStatus != null  and publishStatus != ''"> and publish_status = #{publishStatus}</if>
        </where>
    </select>
    
    <select id="selectVideoContentById" parameterType="Long" resultMap="VideoContentResult">
        <include refid="selectVideoContentVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertVideoContent" parameterType="VideoContent" useGeneratedKeys="true" keyProperty="id">
        insert into video_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="categoryId != null">category_id,</if>
            <if test="title != null">title,</if>
            <if test="picPath != null">pic_path,</if>
            <if test="status != null">status,</if>
            <if test="publishTime != null">publish_time,</if>
            <if test="cancelTime != null">cancel_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            <if test="videoPath != null">video_path,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="checkResult != null">check_result,</if>
            <if test="publishStatus != null">publish_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="categoryId != null">#{categoryId},</if>
            <if test="title != null">#{title},</if>
            <if test="picPath != null">#{picPath},</if>
            <if test="status != null">#{status},</if>
            <if test="publishTime != null">#{publishTime},</if>
            <if test="cancelTime != null">#{cancelTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="videoPath != null">#{videoPath},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="checkResult != null">#{checkResult},</if>
            <if test="publishStatus != null">#{publishStatus},</if>
         </trim>
    </insert>

    <update id="updateVideoContent" parameterType="VideoContent">
        update video_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="categoryId != null">category_id = #{categoryId},</if>
            <if test="title != null">title = #{title},</if>
            <if test="picPath != null">pic_path = #{picPath},</if>
            <if test="status != null">status = #{status},</if>
            <if test="publishTime != null">publish_time = #{publishTime},</if>
            <if test="cancelTime != null">cancel_time = #{cancelTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="videoPath != null">video_path = #{videoPath},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="checkResult != null">check_result = #{checkResult},</if>
            <if test="publishStatus != null">publish_status = #{publishStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVideoContentById" parameterType="Long">
        delete from video_content where id = #{id}
    </delete>

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

    <select id="selectVideoContentVoList" parameterType="VideoContent" resultType="com.ruoyi.abuwx.vo.VideoContentVo">
        select a.id, a.category_id as categoryId, a.title, a.pic_path as picPath, a.status, a.publish_time as publishTime,
        a.cancel_time as cancelTime, a.create_time as createTime,a.update_time as updateTime, a.create_by as createBy,
        a.update_by as updateBy, a.remark, a.video_path as videoPath, a.check_status as checkStatus, a.check_result as checkResult,
        a.publish_status as publishStatus,b.name as categoryName from video_content a
        left join video_category b on a.category_id = b.id
        <where>
            <if test="categoryId != null "> and a.category_id = #{categoryId}</if>
            <if test="title != null  and title != ''"> and a.title = #{title}</if>
            <if test="picPath != null  and picPath != ''"> and a.pic_path = #{picPath}</if>
            <if test="status != null  and status != ''"> and a.status = #{status}</if>
            <if test="publishTime != null "> and a.publish_time = #{publishTime}</if>
            <if test="cancelTime != null "> and a.cancel_time = #{cancelTime}</if>
            <if test="videoPath != null  and videoPath != ''"> and a.video_path = #{videoPath}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and a.check_status = #{checkStatus}</if>
            <if test="checkResult != null  and checkResult != ''"> and a.check_result = #{checkResult}</if>
            <if test="publishStatus != null  and publishStatus != ''"> and a.publish_status = #{publishStatus}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
            <if test="params.beginPublishTime != null and params.beginPublishTime != ''"><!-- 开始时间检索 -->
                and date_format(a.publish_time,'%y%m%d') &gt;= date_format(#{params.beginPublishTime},'%y%m%d')
            </if>
            <if test="params.endPublishTime != null and params.endPublishTime != ''"><!-- 结束时间检索 -->
                and date_format(a.publish_time,'%y%m%d') &lt;= date_format(#{params.endPublishTime},'%y%m%d')
            </if>
        </where>

    </select>
</mapper>