<?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.xiaojukeji.know.streaming.km.persistence.mysql.topic.TopicDAO">
    <resultMap id="TopicMap"                type="com.xiaojukeji.know.streaming.km.common.bean.po.topic.TopicPO">
        <id column="id"                       property="id" />
        <result column="create_time"          property="createTime" />
        <result column="update_time"          property="updateTime" />

        <result column="cluster_phy_id"       property="clusterPhyId" />
        <result column="topic_name"           property="topicName" />
        <result column="replica_num"          property="replicaNum" />
        <result column="partition_num"        property="partitionNum" />
        <result column="broker_ids"           property="brokerIds" />
        <result column="partition_map"        property="partitionMap" />
        <result column="retention_ms"         property="retentionMs" />
        <result column="type"                 property="type" />
        <result column="description"          property="description" />
  </resultMap>

    <insert id="replaceAll" parameterType="com.xiaojukeji.know.streaming.km.common.bean.po.topic.TopicPO">
        REPLACE ks_km_topic
            (cluster_phy_id, topic_name, replica_num, partition_num, broker_ids, partition_map, retention_ms, `type`, description)
        VALUES
            (#{clusterPhyId}, #{topicName}, #{replicaNum}, #{partitionNum}, #{brokerIds}, #{partitionMap}, #{retentionMs}, #{type}, #{description})
    </insert>

    <update id="updateConfigById" parameterType="com.xiaojukeji.know.streaming.km.common.bean.po.topic.TopicPO">
        UPDATE ks_km_topic SET retention_ms = #{retentionMs} WHERE id=#{id}
    </update>

</mapper>