<?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.health.HealthCheckResultDAO">
  <resultMap id="ClusterPhyMap"           type="com.xiaojukeji.know.streaming.km.common.bean.po.health.HealthCheckResultPO">
    <id column="id"                       property="id" />
    <result column="create_time"          property="createTime" />
    <result column="update_time"          property="updateTime" />

    <result column="dimension"            property="dimension" />
    <result column="config_name"          property="configName" />
    <result column="cluster_phy_id"       property="clusterPhyId" />
    <result column="res_name"             property="resName" />
    <result column="passed"               property="passed" />
  </resultMap>

  <insert id="replace" parameterType="com.xiaojukeji.know.streaming.km.common.bean.po.health.HealthCheckResultPO">
    REPLACE ks_km_health_check_result
        (dimension, config_name, cluster_phy_id, res_name, passed)
        VALUES
        (#{dimension}, #{configName}, #{clusterPhyId}, #{resName}, #{passed})
  </insert>

  <insert id="batchReplace">
    insert into ks_km_health_check_result (dimension, config_name, cluster_phy_id, res_name, passed)
    values
    <foreach collection="list" item="item" separator=",">
      (#{item.dimension}, #{item.configName}, #{item.clusterPhyId}, #{item.resName}, #{item.passed})
    </foreach>
    on duplicate key update
    dimension = dimension, config_name = config_name, cluster_phy_id = cluster_phy_id,
    res_name = res_name, passed = passed
  </insert>

</mapper>
