<?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="GatewayConfigDao">
    <resultMap id="GatewayConfigMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
        <id column="id"                 property="id" />
        <result column="type"           property="type" />
        <result column="name"           property="name" />
        <result column="value"          property="value" />
        <result column="version"        property="version" />
        <result column="description"    property="description" />
        <result column="create_time"    property="createTime" />
        <result column="modify_time"    property="modifyTime" />
    </resultMap>

    <select id="getByConfigType" parameterType="java.lang.String" resultMap="GatewayConfigMap">
        SELECT * FROM gateway_config WHERE `type`=#{configType}
    </select>

    <select id="getByConfigTypeAndName" parameterType="java.util.Map" resultMap="GatewayConfigMap">
        SELECT * FROM gateway_config WHERE `type`=#{configType} AND `name`=#{configName}
    </select>

    <select id="list" resultMap="GatewayConfigMap">
        SELECT * FROM gateway_config
    </select>

    <insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
        <![CDATA[
        INSERT INTO gateway_config
        (`type`, name, value, version, description)
        VALUES
        (#{type}, #{name}, #{value}, #{version}, #{description})
        ]]>
    </insert>

    <delete id="deleteById" parameterType="java.lang.Long">
        <![CDATA[
        DELETE FROM gateway_config WHERE id=#{id}
        ]]>
    </delete>

    <update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
        <![CDATA[
        UPDATE gateway_config SET
            `type`=#{type},
            `name`=#{name},
            `value`=#{value},
            `version`=#{version},
            `description`=#{description}
        WHERE id=#{id}
        ]]>
    </update>

    <select id="getById" parameterType="java.lang.Long" resultMap="GatewayConfigMap">
        SELECT * FROM gateway_config WHERE id=#{id}
    </select>
</mapper>