<?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.EpsTrafficDataMapper">
    
    <resultMap type="EpsTrafficData" id="EpsTrafficDataResult">
        <result property="id"    column="id"    />
        <result property="hardwareSn"    column="hardware_sn"    />
        <result property="nodeName"    column="node_name"    />
        <result property="revenueMethod"    column="revenue_method"    />
        <result property="trafficPort"    column="traffic_port"    />
        <result property="txBytes"    column="tx_bytes"    />
        <result property="rxBytes"    column="rx_bytes"    />
        <result property="packageBandwidth"    column="package_bandwidth"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="creatorId"    column="creator_id"    />
        <result property="creatorName"    column="creator_name"    />
        <result property="updaterId"    column="updater_id"    />
        <result property="updaterName"    column="updater_name"    />
    </resultMap>

    <sql id="selectEpsTrafficDataVo">
        select id, hardware_sn, node_name, revenue_method, traffic_port, tx_bytes, rx_bytes, package_bandwidth, create_time, update_time, creator_id, creator_name, updater_id, updater_name from eps_traffic_data
    </sql>

    <select id="selectEpsTrafficDataList" parameterType="EpsTrafficData" resultMap="EpsTrafficDataResult">
        <include refid="selectEpsTrafficDataVo"/>
        <where>  
            <if test="hardwareSn != null  and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
            <if test="nodeName != null  and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
            <if test="revenueMethod != null  and revenueMethod != ''"> and revenue_method = #{revenueMethod}</if>
            <if test="trafficPort != null  and trafficPort != ''"> and traffic_port = #{trafficPort}</if>
            <if test="txBytes != null "> and tx_bytes = #{txBytes}</if>
            <if test="rxBytes != null "> and rx_bytes = #{rxBytes}</if>
            <if test="packageBandwidth != null "> and package_bandwidth = #{packageBandwidth}</if>
            <if test="creatorId != null "> and creator_id = #{creatorId}</if>
            <if test="creatorName != null  and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
            <if test="updaterId != null "> and updater_id = #{updaterId}</if>
            <if test="updaterName != null  and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
        </where>
    </select>
    
    <select id="selectEpsTrafficDataById" parameterType="Long" resultMap="EpsTrafficDataResult">
        <include refid="selectEpsTrafficDataVo"/>
        where id = #{id}
    </select>

    <insert id="insertEpsTrafficData" parameterType="EpsTrafficData" useGeneratedKeys="true" keyProperty="id">
        insert into eps_traffic_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="hardwareSn != null">hardware_sn,</if>
            <if test="nodeName != null">node_name,</if>
            <if test="revenueMethod != null">revenue_method,</if>
            <if test="trafficPort != null">traffic_port,</if>
            <if test="txBytes != null">tx_bytes,</if>
            <if test="rxBytes != null">rx_bytes,</if>
            <if test="packageBandwidth != null">package_bandwidth,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="creatorId != null">creator_id,</if>
            <if test="creatorName != null">creator_name,</if>
            <if test="updaterId != null">updater_id,</if>
            <if test="updaterName != null">updater_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="hardwareSn != null">#{hardwareSn},</if>
            <if test="nodeName != null">#{nodeName},</if>
            <if test="revenueMethod != null">#{revenueMethod},</if>
            <if test="trafficPort != null">#{trafficPort},</if>
            <if test="txBytes != null">#{txBytes},</if>
            <if test="rxBytes != null">#{rxBytes},</if>
            <if test="packageBandwidth != null">#{packageBandwidth},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="creatorId != null">#{creatorId},</if>
            <if test="creatorName != null">#{creatorName},</if>
            <if test="updaterId != null">#{updaterId},</if>
            <if test="updaterName != null">#{updaterName},</if>
         </trim>
    </insert>

    <update id="updateEpsTrafficData" parameterType="EpsTrafficData">
        update eps_traffic_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
            <if test="nodeName != null">node_name = #{nodeName},</if>
            <if test="revenueMethod != null">revenue_method = #{revenueMethod},</if>
            <if test="trafficPort != null">traffic_port = #{trafficPort},</if>
            <if test="txBytes != null">tx_bytes = #{txBytes},</if>
            <if test="rxBytes != null">rx_bytes = #{rxBytes},</if>
            <if test="packageBandwidth != null">package_bandwidth = #{packageBandwidth},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="creatorId != null">creator_id = #{creatorId},</if>
            <if test="creatorName != null">creator_name = #{creatorName},</if>
            <if test="updaterId != null">updater_id = #{updaterId},</if>
            <if test="updaterName != null">updater_name = #{updaterName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEpsTrafficDataById" parameterType="Long">
        delete from eps_traffic_data where id = #{id}
    </delete>

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