<?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="cn.pluss.platform.mapper.HelpVideoMapper">

    <insert id="saveHelpVideo" parameterType="cn.pluss.platform.entity.HelpVideo">
        	insert into tb_pluss_help_video(name,createDt,content,videoUrl,type)VALUES(#{name},NOW(),#{content},#{videoUrl},#{type})
    	</insert>

    <insert id="saveHelpVideoBatch">
        insert into tb_pluss_help_video(name,createDt,content,videoUrl,type) VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{name},#{createDt},#{content},#{videoUrl},#{type}		)
        </foreach>
    </insert>

    <select id="queryHelpVideo" parameterType="cn.pluss.platform.entity.HelpVideo" resultType="cn.pluss.platform.entity.HelpVideo">
        SELECT * from tb_pluss_help_video
        <where>
            <if test="id!= null">
                and id = #{id}
            </if>
            <if test="name!= null">
                and name = #{name}
            </if>
            <if test="createDt!= null">
                and createDt = #{createDt}
            </if>
            <if test="content!= null">
                and content = #{content}
            </if>
            <if test="videoUrl!= null">
                and videoUrl = #{videoUrl}
            </if>
            <if test="type!= null">
                and type = #{type}
            </if>
        </where>
    </select>

    <select id="queryHelpVideoList" parameterType="cn.pluss.platform.entity.HelpVideo" resultType="cn.pluss.platform.entity.HelpVideo">
        SELECT * from tb_pluss_help_video
        <where>
            <if test="id!= null">
                and 	id = #{id}
            </if>
            <if test="name!= null">
                and 	name = #{name}
            </if>
            <if test="createDt!= null">
                and 	createDt = #{createDt}
            </if>
            <if test="content!= null">
                and 	content = #{content}
            </if>
            <if test="videoUrl!= null">
                and 	videoUrl = #{videoUrl}
            </if>
            <if test="type!= null">
                and 	type = #{type}
            </if>
        </where>
    </select>

    <update id="updateHelpVideo" parameterType="cn.pluss.platform.entity.HelpVideo" >
        update tb_pluss_help_video
        <set>
            <if test="name!= null">
                name = #{name},
            </if>
            <if test="createDt!= null">
                createDt = #{createDt},
            </if>
            <if test="content!= null">
                content = #{content},
            </if>
            <if test="videoUrl!= null">
                videoUrl = #{videoUrl},
            </if>
            <if test="type!= null">
                type = #{type}
            </if>
        </set>
        where id=#{id}
    </update>

    <delete id="deleteHelpVideo" parameterType="cn.pluss.platform.entity.HelpVideo" >
			DELETE FROM tb_pluss_help_video where id=#{id}
		</delete>

    <select id="queryHelpVideoPage" parameterType="java.util.Map" resultType="cn.pluss.platform.entity.HelpVideo">
        SELECT * from tb_pluss_help_video
        <where>
            <if test="id!= null">
                and id = #{id}
            </if>
            <if test="name!= null">
                and name like CONCAT("%",#{name},"%")
            </if>
            <if test="createDt!= null">
                and createDt = #{createDt}
            </if>
            <if test="content!= null">
                and content = #{content}
            </if>
            <if test="videoUrl!= null">
                and videoUrl = #{videoUrl}
            </if>
            <if test="type!= null">
                and type = #{type}
            </if>
        </where>
        order by sort  limit #{pageSize}  offset  #{offset}
    </select>

    <select id="queryHelpVideoPageCount" parameterType="java.util.Map" resultType="java.lang.Integer">
        SELECT count(*) from tb_pluss_help_video
        <where>
            <if test="id!= null">
                and id = #{id}
            </if>
            <if test="name!= null">
                and name = #{name}
            </if>
            <if test="createDt!= null">
                and createDt = #{createDt}
            </if>
            <if test="content!= null">
                and content = #{content}
            </if>
            <if test="videoUrl!= null">
                and videoUrl = #{videoUrl}
            </if>
            <if test="type!= null">
                and type = #{type}
            </if>
        </where>
    </select>

</mapper>
