<?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.EpsMethodChangeRecordMapper">

    <resultMap type="EpsMethodChangeRecord" id="EpsMethodChangeRecordResult">
        <result property="id"    column="id"    />
        <result property="nodeName"    column="node_name"    />
        <result property="changeContent"    column="change_content"    />
        <result property="hardwareSn"    column="hardware_sn"    />
        <result property="createTime"    column="create_time"    />
        <result property="creatBy"    column="creat_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="revenueMethod"    column="revenue_method"    />
        <result property="trafficPort"    column="traffic_port"    />
        <result property="packageBandwidth"    column="package_bandwidth"    />
        <result property="businessName"    column="business_name"    />
        <result property="businessCode"    column="business_code"    />
        <result property="clientId"    column="client_id"    />
    </resultMap>

    <sql id="selectEpsMethodChangeRecordVo">
        select id, node_name, change_content, hardware_sn, create_time, creat_by, update_time, update_by, revenue_method, traffic_port, package_bandwidth, business_name, business_code, client_id from eps_method_change_record
    </sql>

    <select id="selectEpsMethodChangeRecordList" parameterType="EpsMethodChangeRecord" resultMap="EpsMethodChangeRecordResult">
        <include refid="selectEpsMethodChangeRecordVo"/>
        <where>
            <if test="nodeName != null  and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</if>
            <if test="changeContent != null  and changeContent != ''"> and change_content like concat('%', #{changeContent}, '%')</if>
            <if test="hardwareSn != null  and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
            <if test="creatBy != null  and creatBy != ''"> and creat_by = #{creatBy}</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="packageBandwidth != null "> and package_bandwidth = #{packageBandwidth}</if>
            <if test="businessName != null  and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
            <if test="businessCode != null  and businessCode != ''"> and business_code = #{businessCode}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</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>
        order by create_time desc
    </select>

    <select id="selectEpsMethodChangeRecordById" parameterType="Long" resultMap="EpsMethodChangeRecordResult">
        <include refid="selectEpsMethodChangeRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertEpsMethodChangeRecord" parameterType="EpsMethodChangeRecord">
        insert into eps_method_change_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="nodeName != null">node_name,</if>
            <if test="changeContent != null">change_content,</if>
            <if test="hardwareSn != null">hardware_sn,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creatBy != null">creat_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="revenueMethod != null">revenue_method,</if>
            <if test="trafficPort != null">traffic_port,</if>
            <if test="packageBandwidth != null">package_bandwidth,</if>
            <if test="businessName != null">business_name,</if>
            <if test="businessCode != null">business_code,</if>
            <if test="clientId != null">client_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="nodeName != null">#{nodeName},</if>
            <if test="changeContent != null">#{changeContent},</if>
            <if test="hardwareSn != null">#{hardwareSn},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creatBy != null">#{creatBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="revenueMethod != null">#{revenueMethod},</if>
            <if test="trafficPort != null">#{trafficPort},</if>
            <if test="packageBandwidth != null">#{packageBandwidth},</if>
            <if test="businessName != null">#{businessName},</if>
            <if test="businessCode != null">#{businessCode},</if>
            <if test="clientId != null">#{clientId},</if>
        </trim>
    </insert>

    <update id="updateEpsMethodChangeRecord" parameterType="EpsMethodChangeRecord">
        update eps_method_change_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="nodeName != null">node_name = #{nodeName},</if>
            <if test="changeContent != null">change_content = #{changeContent},</if>
            <if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creatBy != null">creat_by = #{creatBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="revenueMethod != null">revenue_method = #{revenueMethod},</if>
            <if test="trafficPort != null">traffic_port = #{trafficPort},</if>
            <if test="packageBandwidth != null">package_bandwidth = #{packageBandwidth},</if>
            <if test="businessName != null">business_name = #{businessName},</if>
            <if test="businessCode != null">business_code = #{businessCode},</if>
            <if test="clientId != null">client_id = #{clientId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteEpsMethodChangeRecordById" parameterType="Long">
        delete from eps_method_change_record where id = #{id}
    </delete>

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