<?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.zehong.system.mapper.TVideoManagerMapper">
    
    <resultMap type="TVideoManager" id="TVideoManagerResult">
        <result property="videoManagerId"    column="video_manager_id"    />
        <result property="videoName"    column="video_name"    />
        <result property="resourceId"    column="resource_id"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="videoAddress"    column="video_address"    />
        <result property="type"    column="type"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="beyondEnterpriseName"    column="beyond_enterprise_name"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTVideoManagerVo">
        select video_manager_id, video_name, resource_id, longitude, latitude, video_address, type, beyond_enterprise_id, beyond_enterprise_name, create_by, create_time, update_by, update_time, is_del, remarks from t_video_manager
    </sql>

    <select id="selectTVideoManagerList" parameterType="TVideoManager" resultMap="TVideoManagerResult">
        <include refid="selectTVideoManagerVo"/>
        <where> is_del = '0'
            <if test="videoName != null  and videoName != ''"> and video_name like concat('%', #{videoName}, '%')</if>
            <if test="resourceId != null  and resourceId != ''"> and resource_id = #{resourceId}</if>
            <if test="longitude != null "> and longitude = #{longitude}</if>
            <if test="latitude != null "> and latitude = #{latitude}</if>
            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="beyondEnterpriseId != null "> and beyond_enterprise_id = #{beyondEnterpriseId}</if>
            <if test="beyondEnterpriseName != null  and beyondEnterpriseName != ''"> and beyond_enterprise_name like concat('%', #{beyondEnterpriseName}, '%')</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTVideoManagerById" parameterType="Long" resultMap="TVideoManagerResult">
        <include refid="selectTVideoManagerVo"/>
        where video_manager_id = #{videoManagerId}
    </select>
        
    <insert id="insertTVideoManager" parameterType="TVideoManager" useGeneratedKeys="true" keyProperty="videoManagerId">
        insert into t_video_manager
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="videoName != null">video_name,</if>
            <if test="resourceId != null">resource_id,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
            <if test="videoAddress != null">video_address,</if>
            <if test="type != null">type,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="videoName != null">#{videoName},</if>
            <if test="resourceId != null">#{resourceId},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
            <if test="videoAddress != null">#{videoAddress},</if>
            <if test="type != null">#{type},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">#{beyondEnterpriseName},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTVideoManager" parameterType="TVideoManager">
        update t_video_manager
        <trim prefix="SET" suffixOverrides=",">
            <if test="videoName != null">video_name = #{videoName},</if>
            <if test="resourceId != null">resource_id = #{resourceId},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
            <if test="videoAddress != null">video_address = #{videoAddress},</if>
            <if test="type != null">type = #{type},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name = #{beyondEnterpriseName},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where video_manager_id = #{videoManagerId}
    </update>

    <delete id="deleteTVideoManagerById" parameterType="Long">
        delete from t_video_manager where video_manager_id = #{videoManagerId}
    </delete>

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