<?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.RmSwitchInterfaceInfoMapper">
    
    <resultMap type="RmSwitchInterfaceInfo" id="RmSwitchInterfaceInfoResult">
        <result property="id"    column="id"    />
        <result property="hardwareSn"    column="hardware_sn"    />
        <result property="switchName"    column="switch_name"    />
        <result property="interfaceName"    column="interface_name"    />
        <result property="interfaceRemark"    column="interface_remark"    />
        <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"    />
    </resultMap>

    <sql id="selectRmSwitchInterfaceInfoVo">
        select id, hardware_sn, switch_name, interface_name, interface_remark, create_time, update_time, create_by, update_by, client_id from rm_switch_interface_info
    </sql>

    <select id="selectRmSwitchInterfaceInfoList" parameterType="RmSwitchInterfaceInfo" resultMap="RmSwitchInterfaceInfoResult">
        <include refid="selectRmSwitchInterfaceInfoVo"/>
        <where>  
            <if test="hardwareSn != null  and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
            <if test="switchName != null  and switchName != ''"> and switch_name like concat('%', #{switchName}, '%')</if>
            <if test="interfaceName != null  and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
            <if test="interfaceRemark != null  and interfaceRemark != ''"> and interface_remark = #{interfaceRemark}</if>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
        </where>
    </select>
    
    <select id="selectRmSwitchInterfaceInfoById" parameterType="Long" resultMap="RmSwitchInterfaceInfoResult">
        <include refid="selectRmSwitchInterfaceInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmSwitchInterfaceInfo" parameterType="RmSwitchInterfaceInfo" useGeneratedKeys="true" keyProperty="id">
        insert into rm_switch_interface_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="hardwareSn != null and hardwareSn != ''">hardware_sn,</if>
            <if test="switchName != null and switchName != ''">switch_name,</if>
            <if test="interfaceName != null and interfaceName != ''">interface_name,</if>
            <if test="interfaceRemark != null">interface_remark,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="hardwareSn != null and hardwareSn != ''">#{hardwareSn},</if>
            <if test="switchName != null and switchName != ''">#{switchName},</if>
            <if test="interfaceName != null and interfaceName != ''">#{interfaceName},</if>
            <if test="interfaceRemark != null">#{interfaceRemark},</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>
         </trim>
    </insert>

    <update id="updateRmSwitchInterfaceInfo" parameterType="RmSwitchInterfaceInfo">
        update rm_switch_interface_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="hardwareSn != null and hardwareSn != ''">hardware_sn = #{hardwareSn},</if>
            <if test="switchName != null and switchName != ''">switch_name = #{switchName},</if>
            <if test="interfaceName != null and interfaceName != ''">interface_name = #{interfaceName},</if>
            <if test="interfaceRemark != null">interface_remark = #{interfaceRemark},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRmSwitchInterfaceInfoById" parameterType="Long">
        delete from rm_switch_interface_info where id = #{id}
    </delete>

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