<?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.sf.service.gateway.mapper.GatewayConfigMapper">

    <resultMap id="BaseResultMap" type="com.sf.service.gateway.domain.GatewayConfig">
            <id property="appCode" column="app_code" jdbcType="VARCHAR"/>
            <result property="dataEncryptionStatus" column="data_encryption_status" jdbcType="CHAR"/>
            <result property="encryptionAlgorithm" column="encryption_algorithm" jdbcType="VARCHAR"/>
            <result property="privateKey" column="private_key" jdbcType="VARCHAR"/>
            <result property="publicKey" column="public_key" jdbcType="VARCHAR"/>
            <result property="apiCurrentLimitingStatus" column="api_current_limiting_status" jdbcType="CHAR"/>
            <result property="apiCurrentLimitingThreshold" column="api_current_limiting_threshold" jdbcType="INTEGER"/>
            <result property="apiCurrentLimitingTimeWindow" column="api_current_limiting_time_window" jdbcType="INTEGER"/>
            <result property="apiCurrentLimitingDefaultResponse" column="api_current_limiting_default_response" jdbcType="VARCHAR"/>
            <result property="appCurrentLimitingStatus" column="app_current_limiting_status" jdbcType="CHAR"/>
            <result property="appCurrentLimitingThreshold" column="app_current_limiting_threshold" jdbcType="INTEGER"/>
            <result property="appCurrentLimitingTimeWindow" column="app_current_limiting_time_window" jdbcType="INTEGER"/>
            <result property="appCurrentLimitingDefaultResponse" column="app_current_limiting_default_response" jdbcType="VARCHAR"/>
            <result property="created" column="created" jdbcType="VARCHAR"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
            <result property="modified" column="modified" jdbcType="VARCHAR"/>
            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        app_code,data_encryption_status,encryption_algorithm,
        private_key,public_key,api_current_limiting_status,
        api_current_limiting_threshold,api_current_limiting_time_window,api_current_limiting_default_response,
        app_current_limiting_status,app_current_limiting_threshold,app_current_limiting_time_window,
        app_current_limiting_default_response,created,create_time,
        modified,update_time
    </sql>

    <select id="selectByAppCode" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from Gateway_config
        where  app_code = #{appCode,jdbcType=VARCHAR} 
    </select>

    <delete id="deleteByAppCode" parameterType="java.lang.String">
        delete from Gateway_config
        where  app_code = #{appCode,jdbcType=VARCHAR} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.sf.service.gateway.domain.GatewayConfig" useGeneratedKeys="true">
        insert into Gateway_config
        ( app_code,data_encryption_status,encryption_algorithm
        ,private_key,public_key,api_current_limiting_status
        ,api_current_limiting_threshold,api_current_limiting_time_window,api_current_limiting_default_response
        ,app_current_limiting_status,app_current_limiting_threshold,app_current_limiting_time_window
        ,app_current_limiting_default_response,created,create_time
        ,modified,update_time)
        values (#{appCode,jdbcType=VARCHAR},#{dataEncryptionStatus,jdbcType=CHAR},#{encryptionAlgorithm,jdbcType=VARCHAR}
        ,#{privateKey,jdbcType=VARCHAR},#{publicKey,jdbcType=VARCHAR},#{apiCurrentLimitingStatus,jdbcType=CHAR}
        ,#{apiCurrentLimitingThreshold,jdbcType=INTEGER},#{apiCurrentLimitingTimeWindow,jdbcType=INTEGER},#{apiCurrentLimitingDefaultResponse,jdbcType=VARCHAR}
        ,#{appCurrentLimitingStatus,jdbcType=CHAR},#{appCurrentLimitingThreshold,jdbcType=INTEGER},#{appCurrentLimitingTimeWindow,jdbcType=INTEGER}
        ,#{appCurrentLimitingDefaultResponse,jdbcType=VARCHAR},#{created,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP}
        ,#{modified,jdbcType=VARCHAR},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.sf.service.gateway.domain.GatewayConfig" useGeneratedKeys="true">
        insert into Gateway_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="appCode != null">appCode,</if>
                <if test="dataEncryptionStatus != null">dataEncryptionStatus,</if>
                <if test="encryptionAlgorithm != null">encryptionAlgorithm,</if>
                <if test="privateKey != null">privateKey,</if>
                <if test="publicKey != null">publicKey,</if>
                <if test="apiCurrentLimitingStatus != null">apiCurrentLimitingStatus,</if>
                <if test="apiCurrentLimitingThreshold != null">apiCurrentLimitingThreshold,</if>
                <if test="apiCurrentLimitingTimeWindow != null">apiCurrentLimitingTimeWindow,</if>
                <if test="apiCurrentLimitingDefaultResponse != null">apiCurrentLimitingDefaultResponse,</if>
                <if test="appCurrentLimitingStatus != null">appCurrentLimitingStatus,</if>
                <if test="appCurrentLimitingThreshold != null">appCurrentLimitingThreshold,</if>
                <if test="appCurrentLimitingTimeWindow != null">appCurrentLimitingTimeWindow,</if>
                <if test="appCurrentLimitingDefaultResponse != null">appCurrentLimitingDefaultResponse,</if>
                <if test="created != null">created,</if>
                <if test="createTime != null">createTime,</if>
                <if test="modified != null">modified,</if>
                <if test="updateTime != null">updateTime,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="appCode != null">app_code = #{appCode,jdbcType=VARCHAR},</if>
                <if test="dataEncryptionStatus != null">data_encryption_status = #{dataEncryptionStatus,jdbcType=CHAR},</if>
                <if test="encryptionAlgorithm != null">encryption_algorithm = #{encryptionAlgorithm,jdbcType=VARCHAR},</if>
                <if test="privateKey != null">private_key = #{privateKey,jdbcType=VARCHAR},</if>
                <if test="publicKey != null">public_key = #{publicKey,jdbcType=VARCHAR},</if>
                <if test="apiCurrentLimitingStatus != null">api_current_limiting_status = #{apiCurrentLimitingStatus,jdbcType=CHAR},</if>
                <if test="apiCurrentLimitingThreshold != null">api_current_limiting_threshold = #{apiCurrentLimitingThreshold,jdbcType=INTEGER},</if>
                <if test="apiCurrentLimitingTimeWindow != null">api_current_limiting_time_window = #{apiCurrentLimitingTimeWindow,jdbcType=INTEGER},</if>
                <if test="apiCurrentLimitingDefaultResponse != null">api_current_limiting_default_response = #{apiCurrentLimitingDefaultResponse,jdbcType=VARCHAR},</if>
                <if test="appCurrentLimitingStatus != null">app_current_limiting_status = #{appCurrentLimitingStatus,jdbcType=CHAR},</if>
                <if test="appCurrentLimitingThreshold != null">app_current_limiting_threshold = #{appCurrentLimitingThreshold,jdbcType=INTEGER},</if>
                <if test="appCurrentLimitingTimeWindow != null">app_current_limiting_time_window = #{appCurrentLimitingTimeWindow,jdbcType=INTEGER},</if>
                <if test="appCurrentLimitingDefaultResponse != null">app_current_limiting_default_response = #{appCurrentLimitingDefaultResponse,jdbcType=VARCHAR},</if>
                <if test="created != null">created = #{created,jdbcType=VARCHAR},</if>
                <if test="createTime != null">create_time = #{createTime,jdbcType=TIMESTAMP},</if>
                <if test="modified != null">modified = #{modified,jdbcType=VARCHAR},</if>
                <if test="updateTime != null">update_time = #{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByAppCodeSelective" parameterType="com.sf.service.gateway.domain.GatewayConfig">
        update Gateway_config
        <set>
                <if test="dataEncryptionStatus != null">
                    data_encryption_status = #{dataEncryptionStatus,jdbcType=CHAR},
                </if>
                <if test="encryptionAlgorithm != null">
                    encryption_algorithm = #{encryptionAlgorithm,jdbcType=VARCHAR},
                </if>
                <if test="privateKey != null">
                    private_key = #{privateKey,jdbcType=VARCHAR},
                </if>
                <if test="publicKey != null">
                    public_key = #{publicKey,jdbcType=VARCHAR},
                </if>
                <if test="apiCurrentLimitingStatus != null">
                    api_current_limiting_status = #{apiCurrentLimitingStatus,jdbcType=CHAR},
                </if>
                <if test="apiCurrentLimitingThreshold != null">
                    api_current_limiting_threshold = #{apiCurrentLimitingThreshold,jdbcType=INTEGER},
                </if>
                <if test="apiCurrentLimitingTimeWindow != null">
                    api_current_limiting_time_window = #{apiCurrentLimitingTimeWindow,jdbcType=INTEGER},
                </if>
                <if test="apiCurrentLimitingDefaultResponse != null">
                    api_current_limiting_default_response = #{apiCurrentLimitingDefaultResponse,jdbcType=VARCHAR},
                </if>
                <if test="appCurrentLimitingStatus != null">
                    app_current_limiting_status = #{appCurrentLimitingStatus,jdbcType=CHAR},
                </if>
                <if test="appCurrentLimitingThreshold != null">
                    app_current_limiting_threshold = #{appCurrentLimitingThreshold,jdbcType=INTEGER},
                </if>
                <if test="appCurrentLimitingTimeWindow != null">
                    app_current_limiting_time_window = #{appCurrentLimitingTimeWindow,jdbcType=INTEGER},
                </if>
                <if test="appCurrentLimitingDefaultResponse != null">
                    app_current_limiting_default_response = #{appCurrentLimitingDefaultResponse,jdbcType=VARCHAR},
                </if>
                <if test="created != null">
                    created = #{created,jdbcType=VARCHAR},
                </if>
                <if test="createTime != null">
                    create_time = #{createTime,jdbcType=TIMESTAMP},
                </if>
                <if test="modified != null">
                    modified = #{modified,jdbcType=VARCHAR},
                </if>
                <if test="updateTime != null">
                    update_time = #{updateTime,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   app_code = #{appCode,jdbcType=VARCHAR} 
    </update>
    <update id="updateByAppCode" parameterType="com.sf.service.gateway.domain.GatewayConfig">
        update Gateway_config
        set 
            data_encryption_status =  #{dataEncryptionStatus,jdbcType=CHAR},
            encryption_algorithm =  #{encryptionAlgorithm,jdbcType=VARCHAR},
            private_key =  #{privateKey,jdbcType=VARCHAR},
            public_key =  #{publicKey,jdbcType=VARCHAR},
            api_current_limiting_status =  #{apiCurrentLimitingStatus,jdbcType=CHAR},
            api_current_limiting_threshold =  #{apiCurrentLimitingThreshold,jdbcType=INTEGER},
            api_current_limiting_time_window =  #{apiCurrentLimitingTimeWindow,jdbcType=INTEGER},
            api_current_limiting_default_response =  #{apiCurrentLimitingDefaultResponse,jdbcType=VARCHAR},
            app_current_limiting_status =  #{appCurrentLimitingStatus,jdbcType=CHAR},
            app_current_limiting_threshold =  #{appCurrentLimitingThreshold,jdbcType=INTEGER},
            app_current_limiting_time_window =  #{appCurrentLimitingTimeWindow,jdbcType=INTEGER},
            app_current_limiting_default_response =  #{appCurrentLimitingDefaultResponse,jdbcType=VARCHAR},
            created =  #{created,jdbcType=VARCHAR},
            create_time =  #{createTime,jdbcType=TIMESTAMP},
            modified =  #{modified,jdbcType=VARCHAR},
            update_time =  #{updateTime,jdbcType=TIMESTAMP}
        where   app_code = #{appCode,jdbcType=VARCHAR} 
    </update>
</mapper>
