<?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.rocketmq.mapper.RmFrpcConfigManageMapper">

    <resultMap type="RmFrpcConfigManage" id="RmFrpcConfigManageResult">
        <result property="id"    column="id"    />
        <result property="clientId"    column="client_id"    />
        <result property="frpcServerAddr"    column="frpc_server_addr"    />
        <result property="frpcServerPort"    column="frpc_server_port"    />
        <result property="frpcRemotePort"    column="frpc_remote_port"    />
        <result property="frpcLocalPort"    column="frpc_local_port"    />
        <result property="frpcType"    column="frpc_type"    />
        <result property="frpcName"    column="frpc_name"    />
        <result property="frpcConnectionStatus"    column="frpc_connection_status"    />
        <result property="frpcCreateTime"    column="frpc_create_time"    />
        <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="frpcLocalIp"    column="frpc_local_ip"    />
        <result property="frpcStatus"    column="frpc_status"    />
    </resultMap>

    <sql id="selectRmFrpcConfigManageVo">
        select id, client_id, frpc_server_addr, frpc_server_port, frpc_remote_port, frpc_local_port, frpc_type, frpc_name, frpc_connection_status, frpc_create_time, create_time, update_time, create_by, update_by, frpc_local_ip, frpc_status from rm_frpc_config_manage
    </sql>

    <select id="selectRmFrpcConfigManageList" parameterType="RmFrpcConfigManage" resultMap="RmFrpcConfigManageResult">
        <include refid="selectRmFrpcConfigManageVo"/>
        <where>
            <if test="clientId != null  and clientId != ''"> and client_id = #{clientId}</if>
            <if test="frpcServerAddr != null  and frpcServerAddr != ''"> and frpc_server_addr = #{frpcServerAddr}</if>
            <if test="frpcServerPort != null  and frpcServerPort != ''"> and frpc_server_port = #{frpcServerPort}</if>
            <if test="frpcRemotePort != null  and frpcRemotePort != ''"> and frpc_remote_port = #{frpcRemotePort}</if>
            <if test="frpcLocalPort != null  and frpcLocalPort != ''"> and frpc_local_port = #{frpcLocalPort}</if>
            <if test="frpcName != null  and frpcName != ''"> and frpc_name like concat('%', #{frpcName}, '%')</if>
            <if test="frpcConnectionStatus != null "> and frpc_connection_status = #{frpcConnectionStatus}</if>
            <if test="frpcCreateTime != null "> and frpc_create_time = #{frpcCreateTime}</if>
            <if test="frpcLocalIp != null  and frpcLocalIp != ''"> and frpc_local_ip = #{frpcLocalIp}</if>
            <if test="frpcStatus != null  and frpcStatus != ''"> and frpc_status = #{frpcStatus}</if>
        </where>
    </select>

    <select id="selectRmFrpcConfigManageById" parameterType="Long" resultMap="RmFrpcConfigManageResult">
        <include refid="selectRmFrpcConfigManageVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmFrpcConfigManage" parameterType="RmFrpcConfigManage" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO rm_frpc_config_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="clientId != null">client_id,</if>
            <if test="frpcServerAddr != null">frpc_server_addr,</if>
            <if test="frpcServerPort != null">frpc_server_port,</if>
            <if test="frpcRemotePort != null">frpc_remote_port,</if>
            <if test="frpcLocalPort != null">frpc_local_port,</if>
            <if test="frpcName != null">frpc_name,</if>
            <if test="frpcConnectionStatus != null">frpc_connection_status,</if>
            <if test="frpcCreateTime != null">frpc_create_time,</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="frpcLocalIp != null">frpc_local_ip,</if>
            <if test="frpcStatus != null">frpc_status,</if>
            <if test="frpcType != null">frpc_type,</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="clientId != null">#{clientId},</if>
            <if test="frpcServerAddr != null">#{frpcServerAddr},</if>
            <if test="frpcServerPort != null">#{frpcServerPort},</if>
            <if test="frpcRemotePort != null">#{frpcRemotePort},</if>
            <if test="frpcLocalPort != null">#{frpcLocalPort},</if>
            <if test="frpcName != null">#{frpcName},</if>
            <if test="frpcConnectionStatus != null">#{frpcConnectionStatus},</if>
            <if test="frpcCreateTime != null">#{frpcCreateTime},</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="frpcLocalIp != null">#{frpcLocalIp},</if>
            <if test="frpcStatus != null">#{frpcStatus},</if>
            <if test="frpcType != null">#{frpcType},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim suffixOverrides=",">
            <if test="frpcServerAddr != null">frpc_server_addr = VALUES(frpc_server_addr),</if>
            <if test="frpcServerPort != null">frpc_server_port = VALUES(frpc_server_port),</if>
            <if test="frpcRemotePort != null">frpc_remote_port = VALUES(frpc_remote_port),</if>
            <if test="frpcLocalPort != null">frpc_local_port = VALUES(frpc_local_port),</if>
            <if test="frpcName != null">frpc_name = VALUES(frpc_name),</if>
            <if test="frpcConnectionStatus != null">frpc_connection_status = VALUES(frpc_connection_status),</if>
            <if test="frpcCreateTime != null">frpc_create_time = VALUES(frpc_create_time),</if>
            <if test="updateTime != null">update_time = VALUES(update_time),</if>
            <if test="updateBy != null">update_by = VALUES(update_by),</if>
            <if test="frpcLocalIp != null">frpc_local_ip = VALUES(frpc_local_ip),</if>
            <if test="frpcStatus != null">frpc_status = VALUES(frpc_status),</if>
            <if test="frpcType != null">frpc_type = VALUES(frpc_type),</if>
        </trim>
    </insert>

    <update id="updateRmFrpcConfigManage" parameterType="RmFrpcConfigManage">
        update rm_frpc_config_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="frpcServerAddr != null">frpc_server_addr = #{frpcServerAddr},</if>
            <if test="frpcServerPort != null">frpc_server_port = #{frpcServerPort},</if>
            <if test="frpcRemotePort != null">frpc_remote_port = #{frpcRemotePort},</if>
            <if test="frpcLocalPort != null">frpc_local_port = #{frpcLocalPort},</if>
            <if test="frpcName != null">frpc_name = #{frpcName},</if>
            <if test="frpcConnectionStatus != null">frpc_connection_status = #{frpcConnectionStatus},</if>
            <if test="frpcCreateTime != null">frpc_create_time = #{frpcCreateTime},</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="frpcLocalIp != null">frpc_local_ip = #{frpcLocalIp},</if>
            <if test="frpcStatus != null">frpc_status = #{frpcStatus},</if>
            <if test="frpcType != null">frpc_type = #{frpcType},</if>
        </trim>
        <where>
            <choose>
                <when test="id != null">
                    and id = #{id}
                </when>
                <when test="clientId != null">
                    and client_id = #{clientId}
                </when>
                <otherwise>
                    and 1=0
                </otherwise>
            </choose>
        </where>
    </update>

    <delete id="deleteRmFrpcConfigManageById" parameterType="Long">
        delete from rm_frpc_config_manage where id = #{id}
    </delete>

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