<?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.judong.chuanyiserver.dao.ConnectDao">

    <insert id="saveConnect">
        insert into sys_server_information(user_id, ip_address, ip_user_name, ip_password, agreement_type, create_time)
            value (#{userId}, #{ipAddress}, #{ipUserName}, #{ipPassword}, #{agreementType}, now())
    </insert>
    <update id="editConnect">
        update sys_server_information
        set ip_address=#{ipAddress},
            ip_user_name=#{ipUserName},
            ip_password=#{ipPassword},
            agreement_type=#{agreementType}
        where id = #{id}
    </update>
    <delete id="deleteConnect">
        delete
        from sys_server_information
        where id = #{id}
          and user_id = #{userId}
    </delete>
    <select id="getServerInformation" resultType="com.judong.chuanyiserver.entity.ServerInformation">
        select id, user_id, ip_address, ip_user_name, ip_password, agreement_type, create_time
        from sys_server_information
        where user_id = #{userId}
          and ip_address = #{ipAddress}
    </select>
    <select id="getServerInformationById" resultType="com.judong.chuanyiserver.entity.ServerInformation">
        select id, user_id, ip_address, ip_user_name, ip_password, agreement_type, create_time
        from sys_server_information
        where id = #{id}
    </select>
    <select id="selectAllConnect" resultType="com.judong.chuanyiserver.entity.ServerInformation">
        select id, ip_address, agreement_type, create_time
        from sys_server_information
        where user_id = #{userId}
        order by create_time desc
    </select>
    <select id="getServerInformationEdit" resultType="com.judong.chuanyiserver.entity.ServerInformation">
        select id, user_id, ip_address, ip_user_name, ip_password, agreement_type, create_time
        from sys_server_information
        where user_id = #{userId}
          and ip_address = #{ipAddress}
          and id != #{id}
    </select>
</mapper>