<?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.system.mapper.video.VideoDeviceInfoMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.video.VideoDeviceInfo">
                    <id column="device_id" property="deviceId" />
                    <result column="device_name" property="deviceName" />
                    <result column="device_ip" property="deviceIp" />
                    <result column="device_port" property="devicePort" />
                    <result column="device_code" property="deviceCode" />
        </resultMap>

        <!-- 通用查询结果列 -->
        <sql id="Base_Column_List">
        select
        device_id, device_name, device_ip, device_port, device_code
        from video_device_info
        </sql>


    <select id="selectVideoDeviceInfoList" parameterType="com.ruoyi.system.domain.video.VideoDeviceInfo" resultMap="BaseResultMap">
        <include refid="Base_Column_List"/>
        <where>
        <if test="deviceId != null  and deviceId != ''"> and device_id = #{deviceId} </if>
        <if test="deviceName != null  and deviceName != ''"> and device_name = #{deviceName} </if>
        <if test="deviceIp != null  and deviceIp != ''"> and device_ip = #{deviceIp} </if>
        <if test="devicePort != null  and devicePort != ''"> and device_port = #{devicePort} </if>
        <if test="deviceCode != null  and deviceCode != ''"> and device_code = #{deviceCode} </if>
        </where>
    </select>

    <select id="selectVideoDeviceInfoById" parameterType="Long" resultMap="BaseResultMap">
        <include refid="Base_Column_List"/>
        where id = #{id}
    </select>

    <insert id="InsertVideoDeviceInfo" parameterType="com.ruoyi.system.domain.video.VideoDeviceInfo">
        insert into video_device_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
        <if test="deviceId != null  and deviceId != ''"> device_id, </if>
        <if test="deviceName != null  and deviceName != ''"> device_name, </if>
        <if test="deviceIp != null  and deviceIp != ''"> device_ip, </if>
        <if test="devicePort != null  and devicePort != ''"> device_port, </if>
        <if test="deviceCode != null  and deviceCode != ''"> device_code, </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceId != null  and deviceId != ''"> #{deviceId}, </if>
                    <if test="deviceName != null  and deviceName != ''"> #{deviceName}, </if>
                    <if test="deviceIp != null  and deviceIp != ''"> #{deviceIp}, </if>
                    <if test="devicePort != null  and devicePort != ''"> #{devicePort}, </if>
                    <if test="deviceCode != null  and deviceCode != ''"> #{deviceCode}, </if>
        </trim>
    </insert>

    <update id="UpdateVideoDeviceInfo" parameterType="com.ruoyi.system.domain.video.VideoDeviceInfo">
        update video_device_info
        <trim prefix="SET" suffixOverrides=",">
                    <if test="deviceName != null"> device_name = #{deviceName}, </if>
                    <if test="deviceIp != null"> device_ip = #{deviceIp}, </if>
                    <if test="devicePort != null"> device_port = #{devicePort}, </if>
                    <if test="deviceCode != null"> device_code = #{deviceCode}, </if>
        </trim>
        where id = #{id}
    </update>

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


</mapper>
