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

    <resultMap type="RmNetworkInterface" id="RmNetworkInterfaceResult">
        <result property="id"    column="id"    />
        <result property="clientId"    column="client_id"    />
        <result property="isp"    column="isp"    />
        <result property="province"    column="province"    />
        <result property="city"    column="city"    />
        <result property="publicIp"    column="public_ip"    />
        <result property="interfaceName"    column="interface_name"    />
        <result property="macAddress"    column="mac_address"    />
        <result property="interfaceType"    column="interface_type"    />
        <result property="ipv4Address"    column="ipv4_address"    />
        <result property="gateway"    column="gateway"    />
        <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="bindIp"    column="bind_ip"    />
        <result property="newFlag"    column="new_flag"    />
    </resultMap>

    <sql id="selectRmNetworkInterfaceVo">
        select id, client_id, isp, province, city, public_ip, interface_name, mac_address, interface_type, ipv4_address, gateway, create_time, update_time, create_by, update_by, bind_ip, new_flag from rm_network_interface
    </sql>

    <select id="selectRmNetworkInterfaceList" parameterType="RmNetworkInterface" resultMap="RmNetworkInterfaceResult">
        <include refid="selectRmNetworkInterfaceVo"/>
        <where>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
            <if test="isp != null  and isp != ''"> and isp = #{isp}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="publicIp != null  and publicIp != ''"> and public_ip = #{publicIp}</if>
            <if test="interfaceName != null  and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
            <if test="macAddress != null  and macAddress != ''"> and mac_address = #{macAddress}</if>
            <if test="interfaceType != null  and interfaceType != ''"> and interface_type = #{interfaceType}</if>
            <if test="ipv4Address != null  and ipv4Address != ''"> and ipv4_address = #{ipv4Address}</if>
            <if test="gateway != null  and gateway != ''"> and gateway = #{gateway}</if>
            <if test="bindIp != null  and bindIp != ''"> and bind_ip = #{bindIp}</if>
            <if test="newFlag != null "> and new_flag = #{newFlag}</if>
        </where>
    </select>

    <select id="selectRmNetworkInterfaceById" parameterType="Long" resultMap="RmNetworkInterfaceResult">
        <include refid="selectRmNetworkInterfaceVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmNetworkInterface" parameterType="RmNetworkInterface" useGeneratedKeys="true" keyProperty="id">
        insert into rm_network_interface
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">client_id,</if>
            <if test="isp != null">isp,</if>
            <if test="province != null">province,</if>
            <if test="city != null">city,</if>
            <if test="publicIp != null">public_ip,</if>
            <if test="interfaceName != null and interfaceName != ''">interface_name,</if>
            <if test="macAddress != null">mac_address,</if>
            <if test="interfaceType != null">interface_type,</if>
            <if test="ipv4Address != null">ipv4_address,</if>
            <if test="gateway != null">gateway,</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="bindIp != null">bind_ip,</if>
            <if test="newFlag != null">new_flag,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">#{clientId},</if>
            <if test="isp != null">#{isp},</if>
            <if test="province != null">#{province},</if>
            <if test="city != null">#{city},</if>
            <if test="publicIp != null">#{publicIp},</if>
            <if test="interfaceName != null and interfaceName != ''">#{interfaceName},</if>
            <if test="macAddress != null">#{macAddress},</if>
            <if test="interfaceType != null">#{interfaceType},</if>
            <if test="ipv4Address != null">#{ipv4Address},</if>
            <if test="gateway != null">#{gateway},</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="bindIp != null">#{bindIp},</if>
            <if test="newFlag != null">#{newFlag},</if>
        </trim>
    </insert>

    <update id="updateRmNetworkInterface" parameterType="RmNetworkInterface">
        update rm_network_interface
        <trim prefix="SET" suffixOverrides=",">
            <if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
            <if test="isp != null">isp = #{isp},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="publicIp != null">public_ip = #{publicIp},</if>
            <if test="interfaceName != null and interfaceName != ''">interface_name = #{interfaceName},</if>
            <if test="macAddress != null">mac_address = #{macAddress},</if>
            <if test="interfaceType != null">interface_type = #{interfaceType},</if>
            <if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
            <if test="gateway != null">gateway = #{gateway},</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="bindIp != null">bind_ip = #{bindIp},</if>
            <if test="newFlag != null">new_flag = #{newFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRmNetworkInterfaceById" parameterType="Long">
        delete from rm_network_interface where id = #{id}
    </delete>

    <delete id="deleteRmNetworkInterfaceByIds" parameterType="String">
        delete from rm_network_interface where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <update id="updateRmNetworkInterfaceByMac" parameterType="RmNetworkInterface">
        update rm_network_interface
        <trim prefix="SET" suffixOverrides=",">
            <if test="isp != null">isp = #{isp},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="publicIp != null">public_ip = #{publicIp},</if>
            <if test="interfaceName != null and interfaceName != ''">interface_name = #{interfaceName},</if>
            <if test="macAddress != null">mac_address = #{macAddress},</if>
            <if test="interfaceType != null">interface_type = #{interfaceType},</if>
            <if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
            <if test="gateway != null">gateway = #{gateway},</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="bindIp != null">bind_ip = #{bindIp},</if>
            <if test="newFlag != null">new_flag = #{newFlag},</if>
        </trim>
        where mac_address = #{macAddress} and clientId = #{clientId}
    </update>
</mapper>