<?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.pcloud.book.record.dao.impl.MapDataDAOImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.record.entity.MapData" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="region_code" property="regionCode" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.pcloud.book.record.entity.MapData" extends="BaseResultMap" >
    <result column="content" property="content" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, region_code, create_time, content
  </sql>
  <sql id="Blob_Column_List" >
    content
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from map
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from map
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.pcloud.book.record.entity.MapData" >
    insert into map (region_code, create_time,
      content)
    values (#{regionCode,jdbcType=VARCHAR}, #{createtTime,jdbcType=TIMESTAMP},
      #{content,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.pcloud.book.record.entity.MapData" >
    insert into map
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="regionCode != null" >
        region_code,
      </if>
      <if test="createtTime != null" >
        create_time,
      </if>
      <if test="content != null" >
        content,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=BIGINT},
      </if>
      <if test="regionCode != null" >
        #{regionCode,jdbcType=VARCHAR},
      </if>
      <if test="createtTime != null" >
        #{createtTime,jdbcType=TIMESTAMP},
      </if>
      <if test="content != null" >
        #{content,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.record.entity.MapData" >
    update map
    <set >
      <if test="regionCode != null" >
        region_code = #{regionCode,jdbcType=VARCHAR},
      </if>
      <if test="createtTime != null" >
        create_time = #{createtTime,jdbcType=TIMESTAMP},
      </if>
      <if test="content != null" >
        content = #{content,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.pcloud.book.record.entity.MapData" >
    update map
    set region_code = #{regionCode,jdbcType=VARCHAR},
      create_time = #{createtTime,jdbcType=TIMESTAMP},
      content = #{content,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pcloud.book.record.entity.MapData" >
    update map
    set region_code = #{regionCode,jdbcType=VARCHAR},
      create_time = #{createtTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>

  <insert id="batchInsert" parameterType="com.pcloud.book.record.entity.MapData" >
    insert into map (region_code, create_time,
    content)
    values
    <foreach collection="list" item="item" index="index" separator="," >
    (#{item.regionCode,jdbcType=VARCHAR}, now(),
    #{item.content,jdbcType=LONGVARCHAR})
    </foreach>
  </insert>
  
  <select id="getJsonData" parameterType="map" resultMap="ResultMapWithBLOBs">
    select
    <include refid="Base_Column_List"/>
    from
    map
    <where>
      <if test="regionCode != null">
        region_code = #{regionCode}
      </if>
    </where>
    order by region_code asc
  </select>

</mapper>