<?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.rocketmq.mapper.InitialBandwidthTrafficTempMapper">
    
    <resultMap type="InitialBandwidthTrafficTemp" id="InitialBandwidthTrafficTempResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="mac"    column="mac"    />
        <result property="status"    column="status"    />
        <result property="type"    column="type"    />
        <result property="ipV4"    column="ipV4"    />
        <result property="inDropped"    column="in_dropped"    />
        <result property="outDropped"    column="out_dropped"    />
        <result property="inSpeed"    column="in_speed"    />
        <result property="outSpeed"    column="out_speed"    />
        <result property="speed"    column="speed"    />
        <result property="duplex"    column="duplex"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="clientId"    column="client_id"    />
        <result property="totalInSpeed"    column="total_in_speed"    />
        <result property="totalOutSpeed"    column="total_out_speed"    />
    </resultMap>

    <sql id="selectInitialBandwidthTrafficTempVo">
        select id, name, mac, status, type, ipV4, in_dropped, out_dropped, in_speed, out_speed, speed, duplex, create_time, update_time, create_by, update_by, client_id, total_in_speed, total_out_speed from initial_bandwidth_traffic_temp
    </sql>

    <select id="selectInitialBandwidthTrafficTempList" parameterType="InitialBandwidthTrafficTemp" resultMap="InitialBandwidthTrafficTempResult">
        <include refid="selectInitialBandwidthTrafficTempVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="mac != null  and mac != ''"> and mac = #{mac}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="ipV4 != null  and ipV4 != ''"> and ipV4 = #{ipV4}</if>
            <if test="inDropped != null "> and in_dropped = #{inDropped}</if>
            <if test="outDropped != null "> and out_dropped = #{outDropped}</if>
            <if test="inSpeed != null  and inSpeed != ''"> and in_speed = #{inSpeed}</if>
            <if test="outSpeed != null  and outSpeed != ''"> and out_speed = #{outSpeed}</if>
            <if test="speed != null  and speed != ''"> and speed = #{speed}</if>
            <if test="duplex != null  and duplex != ''"> and duplex = #{duplex}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
            <if test="totalInSpeed != null  and totalInSpeed != ''"> and total_in_speed = #{totalInSpeed}</if>
            <if test="totalOutSpeed != null  and totalOutSpeed != ''"> and total_out_speed = #{totalOutSpeed}</if>
            <if test="createTime != null"> and create_time = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectInitialBandwidthTrafficTempById" parameterType="Long" resultMap="InitialBandwidthTrafficTempResult">
        <include refid="selectInitialBandwidthTrafficTempVo"/>
        where id = #{id}
    </select>

    <insert id="insertInitialBandwidthTrafficTemp" parameterType="InitialBandwidthTrafficTemp" useGeneratedKeys="true" keyProperty="id">
        insert IGNORE into initial_bandwidth_traffic_temp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="mac != null">mac,</if>
            <if test="status != null">status,</if>
            <if test="type != null">type,</if>
            <if test="ipV4 != null">ipV4,</if>
            <if test="inDropped != null">in_dropped,</if>
            <if test="outDropped != null">out_dropped,</if>
            <if test="inSpeed != null">in_speed,</if>
            <if test="outSpeed != null">out_speed,</if>
            <if test="speed != null">speed,</if>
            <if test="duplex != null">duplex,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="clientId != null">client_id,</if>
            <if test="totalInSpeed != null">total_in_speed,</if>
            <if test="totalOutSpeed != null">total_out_speed,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="mac != null">#{mac},</if>
            <if test="status != null">#{status},</if>
            <if test="type != null">#{type},</if>
            <if test="ipV4 != null">#{ipV4},</if>
            <if test="inDropped != null">#{inDropped},</if>
            <if test="outDropped != null">#{outDropped},</if>
            <if test="inSpeed != null">#{inSpeed},</if>
            <if test="outSpeed != null">#{outSpeed},</if>
            <if test="speed != null">#{speed},</if>
            <if test="duplex != null">#{duplex},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="clientId != null">#{clientId},</if>
            <if test="totalInSpeed != null">#{totalInSpeed},</if>
            <if test="totalOutSpeed != null">#{totalOutSpeed},</if>
         </trim>
    </insert>

    <update id="updateInitialBandwidthTrafficTemp" parameterType="InitialBandwidthTrafficTemp">
        update initial_bandwidth_traffic_temp
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="mac != null">mac = #{mac},</if>
            <if test="status != null">status = #{status},</if>
            <if test="type != null">type = #{type},</if>
            <if test="ipV4 != null">ipV4 = #{ipV4},</if>
            <if test="inDropped != null">in_dropped = #{inDropped},</if>
            <if test="outDropped != null">out_dropped = #{outDropped},</if>
            <if test="inSpeed != null">in_speed = #{inSpeed},</if>
            <if test="outSpeed != null">out_speed = #{outSpeed},</if>
            <if test="speed != null">speed = #{speed},</if>
            <if test="duplex != null">duplex = #{duplex},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="clientId != null">client_id = #{clientId},</if>
            <if test="totalInSpeed != null">total_in_speed = #{totalInSpeed},</if>
            <if test="totalOutSpeed != null">total_out_speed = #{totalOutSpeed},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInitialBandwidthTrafficTempById" parameterType="Long">
        delete from initial_bandwidth_traffic_temp where id = #{id}
    </delete>

    <delete id="deleteInitialBandwidthTrafficTempByIds" parameterType="String">
        delete from initial_bandwidth_traffic_temp where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteTempMsgByClientId" parameterType="String">
        delete from initial_bandwidth_traffic_temp where client_id = #{clientId}
    </delete>

    <insert id="batchInsertServerTemp" parameterType="java.util.List">
        insert IGNORE into initial_bandwidth_traffic_temp
        (
        name, mac, status, type, ipV4, in_dropped, out_dropped,
        in_speed, out_speed, speed, duplex, create_time, update_time,
        create_by, update_by, client_id, total_in_speed, total_out_speed
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.name}, #{item.mac}, #{item.status}, #{item.type}, #{item.ipV4},
            #{item.inDropped}, #{item.outDropped}, #{item.inSpeed}, #{item.outSpeed},
            #{item.speed}, #{item.duplex}, #{item.createTime}, #{item.updateTime},
            #{item.createBy}, #{item.updateBy}, #{item.clientId}, #{item.totalInSpeed},
            #{item.totalOutSpeed}
            )
        </foreach>
    </insert>
</mapper>