<?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.didi.carrera.console.dao.mapper.NodeMapper">
  <resultMap id="BaseResultMap" type="com.didi.carrera.console.dao.model.Node">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
    <result column="model_id" jdbcType="BIGINT" property="modelId" />
    <result column="master_id" jdbcType="BIGINT" property="masterId" />
    <result column="host" jdbcType="VARCHAR" property="host" />
    <result column="node_type" jdbcType="TINYINT" property="nodeType" />
    <result column="is_delete" jdbcType="TINYINT" property="isDelete" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, cluster_id, model_id, master_id, host, node_type, is_delete, create_time, modify_time
  </sql>
  <select id="selectByExample" parameterType="com.didi.carrera.console.dao.model.NodeCriteria" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from node
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="start != null and start >= 0 ">
      limit #{start}
    </if>
    <if test="start != null and start >= 0 and end != null and end >= 0">
      , #{end}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from node
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from node
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.didi.carrera.console.dao.model.NodeCriteria">
    delete from node
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.didi.carrera.console.dao.model.Node" useGeneratedKeys="true">
    insert into node (cluster_id, model_id, master_id, 
      host, node_type, is_delete, 
      create_time, modify_time)
    values (#{clusterId,jdbcType=BIGINT}, #{modelId,jdbcType=BIGINT}, #{masterId,jdbcType=BIGINT}, 
      #{host,jdbcType=VARCHAR}, #{nodeType,jdbcType=TINYINT}, #{isDelete,jdbcType=TINYINT}, 
      #{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.didi.carrera.console.dao.model.Node" useGeneratedKeys="true">
    insert into node
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="clusterId != null">
        cluster_id,
      </if>
      <if test="modelId != null">
        model_id,
      </if>
      <if test="masterId != null">
        master_id,
      </if>
      <if test="host != null">
        host,
      </if>
      <if test="nodeType != null">
        node_type,
      </if>
      <if test="isDelete != null">
        is_delete,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="modifyTime != null">
        modify_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="clusterId != null">
        #{clusterId,jdbcType=BIGINT},
      </if>
      <if test="modelId != null">
        #{modelId,jdbcType=BIGINT},
      </if>
      <if test="masterId != null">
        #{masterId,jdbcType=BIGINT},
      </if>
      <if test="host != null">
        #{host,jdbcType=VARCHAR},
      </if>
      <if test="nodeType != null">
        #{nodeType,jdbcType=TINYINT},
      </if>
      <if test="isDelete != null">
        #{isDelete,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyTime != null">
        #{modifyTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.didi.carrera.console.dao.model.NodeCriteria" resultType="java.lang.Long">
    select count(*) from node
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update node
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.clusterId != null">
        cluster_id = #{record.clusterId,jdbcType=BIGINT},
      </if>
      <if test="record.modelId != null">
        model_id = #{record.modelId,jdbcType=BIGINT},
      </if>
      <if test="record.masterId != null">
        master_id = #{record.masterId,jdbcType=BIGINT},
      </if>
      <if test="record.host != null">
        host = #{record.host,jdbcType=VARCHAR},
      </if>
      <if test="record.nodeType != null">
        node_type = #{record.nodeType,jdbcType=TINYINT},
      </if>
      <if test="record.isDelete != null">
        is_delete = #{record.isDelete,jdbcType=TINYINT},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.modifyTime != null">
        modify_time = #{record.modifyTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update node
    set id = #{record.id,jdbcType=BIGINT},
      cluster_id = #{record.clusterId,jdbcType=BIGINT},
      model_id = #{record.modelId,jdbcType=BIGINT},
      master_id = #{record.masterId,jdbcType=BIGINT},
      host = #{record.host,jdbcType=VARCHAR},
      node_type = #{record.nodeType,jdbcType=TINYINT},
      is_delete = #{record.isDelete,jdbcType=TINYINT},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      modify_time = #{record.modifyTime,jdbcType=TIMESTAMP}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.didi.carrera.console.dao.model.Node">
    update node
    <set>
      <if test="clusterId != null">
        cluster_id = #{clusterId,jdbcType=BIGINT},
      </if>
      <if test="modelId != null">
        model_id = #{modelId,jdbcType=BIGINT},
      </if>
      <if test="masterId != null">
        master_id = #{masterId,jdbcType=BIGINT},
      </if>
      <if test="host != null">
        host = #{host,jdbcType=VARCHAR},
      </if>
      <if test="nodeType != null">
        node_type = #{nodeType,jdbcType=TINYINT},
      </if>
      <if test="isDelete != null">
        is_delete = #{isDelete,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyTime != null">
        modify_time = #{modifyTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.didi.carrera.console.dao.model.Node">
    update node
    set cluster_id = #{clusterId,jdbcType=BIGINT},
      model_id = #{modelId,jdbcType=BIGINT},
      master_id = #{masterId,jdbcType=BIGINT},
      host = #{host,jdbcType=VARCHAR},
      node_type = #{nodeType,jdbcType=TINYINT},
      is_delete = #{isDelete,jdbcType=TINYINT},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      modify_time = #{modifyTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>