<?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.tongran.system.mapper.RmMonitorConfigDetailsMapper">
    
    <resultMap type="RmMonitorConfigDetails" id="RmMonitorConfigDetailsResult">
        <result property="id"    column="id"    />
        <result property="monitorId"    column="monitor_id"    />
        <result property="deployDevice"    column="deploy_device"    />
        <result property="inBytes"    column="in_bytes"    />
        <result property="outBytes"    column="out_bytes"    />
        <result property="inSpeed"    column="in_speed"    />
        <result property="outSpeed"    column="out_speed"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRmMonitorConfigDetailsVo">
        select id, monitor_id, deploy_device, in_bytes, out_bytes, in_speed, out_speed, create_by, update_by, create_time, update_time from rm_monitor_config_details
    </sql>

    <select id="selectRmMonitorConfigDetailsList" parameterType="RmMonitorConfigDetails" resultMap="RmMonitorConfigDetailsResult">
        <include refid="selectRmMonitorConfigDetailsVo"/>
        <where>  
            <if test="monitorId != null "> and monitor_id = #{monitorId}</if>
            <if test="deployDevice != null  and deployDevice != ''"> and deploy_device = #{deployDevice}</if>
            <if test="inBytes != null "> and in_bytes = #{inBytes}</if>
            <if test="outBytes != null "> and out_bytes = #{outBytes}</if>
            <if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
            <if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
            <if test="startTime != null  and startTime != ''"> and create_time &gt;= #{startTime}</if>
            <if test="endTime != null  and endTime != ''"> and create_time &lt;= #{endTime}</if>
        </where>
    </select>
    
    <select id="selectRmMonitorConfigDetailsById" parameterType="Long" resultMap="RmMonitorConfigDetailsResult">
        <include refid="selectRmMonitorConfigDetailsVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmMonitorConfigDetails" parameterType="RmMonitorConfigDetails" useGeneratedKeys="true" keyProperty="id">
        insert into rm_monitor_config_details
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="monitorId != null">monitor_id,</if>
            <if test="deployDevice != null">deploy_device,</if>
            <if test="inBytes != null">in_bytes,</if>
            <if test="outBytes != null">out_bytes,</if>
            <if test="inSpeed != null">in_speed,</if>
            <if test="outSpeed != null">out_speed,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="monitorId != null">#{monitorId},</if>
            <if test="deployDevice != null">#{deployDevice},</if>
            <if test="inBytes != null">#{inBytes},</if>
            <if test="outBytes != null">#{outBytes},</if>
            <if test="inSpeed != null">#{inSpeed},</if>
            <if test="outSpeed != null">#{outSpeed},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateRmMonitorConfigDetails" parameterType="RmMonitorConfigDetails">
        update rm_monitor_config_details
        <trim prefix="SET" suffixOverrides=",">
            <if test="monitorId != null">monitor_id = #{monitorId},</if>
            <if test="deployDevice != null">deploy_device = #{deployDevice},</if>
            <if test="inBytes != null">in_bytes = #{inBytes},</if>
            <if test="outBytes != null">out_bytes = #{outBytes},</if>
            <if test="inSpeed != null">in_speed = #{inSpeed},</if>
            <if test="outSpeed != null">out_speed = #{outSpeed},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRmMonitorConfigDetailsById" parameterType="Long">
        delete from rm_monitor_config_details where id = #{id}
    </delete>

    <delete id="deleteRmMonitorConfigDetailsByIds" parameterType="String">
        delete from rm_monitor_config_details where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteRmMonitorConfigDetailsByMonitorIds" parameterType="Long">
        delete from rm_monitor_config_details where monitor_id in
        <foreach item="monitorId" collection="array" open="(" separator="," close=")">
            #{monitorId}
        </foreach>
    </delete>
    <insert id="batchInsertRmMonitorConfigDetails" parameterType="java.util.List">
        insert IGNORE into rm_monitor_config_details
        (monitor_id, deploy_device, in_bytes, out_bytes, in_speed, out_speed, create_by, update_by, create_time, update_time)
        values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.monitorId},
            #{item.deployDevice},
            #{item.inBytes},
            #{item.outBytes},
            #{item.inSpeed},
            #{item.outSpeed},
            #{item.createBy},
            #{item.updateBy},
            #{item.createTime},
            #{item.updateTime}
            )
        </foreach>
    </insert>
</mapper>