<?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="HeartbeatDao">
    <resultMap id="HeartbeatMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
        <id property="id"                column="id" />
        <result property="createTime"    column="create_time" />
        <result property="modifyTime"    column="modify_time" />
        <result property="ip"            column="ip" />
        <result property="hostname"      column="hostname" />
    </resultMap>

    <insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
      REPLACE heartbeat (ip, hostname) VALUES (#{ip}, #{hostname})
    </insert>

    <select id="selectActiveHosts" parameterType="java.util.Date" resultMap="HeartbeatMap">
        SELECT * FROM heartbeat WHERE modify_time >= #{afterTime} ORDER BY modify_time DESC
    </select>
</mapper>