<?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="im.zhaojun.system.mapper.VideoMapper">

    <resultMap id="BaseResultMap" type="im.zhaojun.system.model.SbtdspsrResult">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <result column="xh" jdbcType="VARCHAR" property="xh"/>
        <result column="sbbh" jdbcType="VARCHAR" property="sbbh"/>
        <result column="tdbh" jdbcType="VARCHAR" property="tdbh"/>
        <result column="tdmc" jdbcType="VARCHAR" property="tdmc"/>
        <result column="xzbh" jdbcType="VARCHAR" property="xzbh"/>
        <result column="jd" jdbcType="VARCHAR" property="jd"/>
        <result column="wd" jdbcType="VARCHAR" property="wd"/>
        <result column="qymc" jdbcType="VARCHAR" property="qymc"/>
        <result column="squrllj" jdbcType="VARCHAR" property="squrllj"/>
    </resultMap>

    <resultMap id="TreeBaseResultMap" type="im.zhaojun.system.model.Menu">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="menu_id" jdbcType="INTEGER" property="menuId"/>
        <result column="parent_id" jdbcType="INTEGER" property="parentId"/>
        <result column="menu_name" jdbcType="VARCHAR" property="menuName"/>
        <result column="url" jdbcType="VARCHAR" property="url"/>
        <result column="perms" jdbcType="VARCHAR" property="perms"/>
        <result column="order_num" jdbcType="INTEGER" property="orderNum"/>
        <result column="create_time" jdbcType="VARCHAR" property="createTime"/>
        <result column="modify_time" jdbcType="VARCHAR" property="modifyTime"/>
        <result column="icon" jdbcType="VARCHAR" property="icon"/>
        <!--<collection property="children" ofType="im.zhaojun.system.model.Menu" select="selectAllTree"-->
                    <!--column="{parent_id = menu_id}"/>-->
    </resultMap>

    <sql id="Base_Column_List">
      id, video_id, video_name, qybh, qymc, x, y, rtsp,  factory, chargeman, chargemanlxdh, create_time, modify_time
    </sql>


    <select id="selectByMutiParam" resultMap="BaseResultMap">
        select a.xh,  a.tdmc,  a.sbbh ,a.tdbh,a.squrllj,a.xzbh,a.jd,a.wd , b.dept_name   qymc
        from sbtdspsr a,(select t1.dept_id, t1.dept_name
        from dept t1
        left join dept t2
        on t1.parent_id = t2.dept_id
        where t1.parent_id = #{deptId}
        or t1.dept_id = #{deptId}
        or t2.parent_id =#{deptId}
        or t2.dept_id = #{deptId})b
        where a.xzbh=b.dept_id
        <if test="videoName != null and  videoName != '' ">
            and tdmc like '%${videoName}%'
        </if>
        order by sbbh
    </select>
    <insert id="insert" parameterType="im.zhaojun.system.model.Video">
        insert into video ( id,video_id, video_name, qybh, qymc, x, y, rtsp, factory, chargeman, chargemanlxdh, create_time, modify_time )
        select  max(decode(id,null,0,id))+1,#{videoId}, #{videoName}, #{qybh,jdbcType=INTEGER},#{qymc}, #{x}, #{y},#{rtsp}, #{factory}, #{chargeman},#{chargemanlxdh},#{createTime} ,#{modifyTime} from  video
    </insert>

    <delete id="delete" parameterType="String">
        delete    from sbtdspsr  where xh = #{id}
    </delete>
    <update id="updateByPrimaryKey" parameterType="im.zhaojun.system.model.Sbtdspsr">
        update sbtdspsr
        set
         sbbh  = #{sbbh ,jdbcType=VARCHAR},
         tdbh  = #{tdbh ,jdbcType=VARCHAR},
        tdmc  = #{tdmc ,jdbcType=VARCHAR},
        xzbh  = #{xzbh ,jdbcType=INTEGER},
        jd  = #{jd ,jdbcType=VARCHAR},
        wd  = #{wd ,jdbcType=VARCHAR},
        squrllj  = #{squrllj ,jdbcType=VARCHAR},
        xgry = #{xgry,jdbcType=VARCHAR},
        xgrq  = #{xgrq ,jdbcType=VARCHAR}
        where xh = #{xh,jdbcType=VARCHAR}
    </update>

</mapper>