<?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.cultivate.dao.impl.CultivateNotifyItemDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.cultivate.entity.CultivateNotifyItem" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="message_id" property="messageId" jdbcType="BIGINT" />
    <result column="content_type" property="contentType" jdbcType="INTEGER" />
    <result column="content" property="content" jdbcType="VARCHAR" />
    <result column="pic_url" property="picUrl" jdbcType="VARCHAR" />
    <result column="resource_id" property="resourceId" jdbcType="BIGINT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
      <result column="serve_id" jdbcType="BIGINT" property="serveId"/>
      <result column="serve_type" jdbcType="TINYINT" property="serveType"/>
      <result column="jump_type" jdbcType="INTEGER" property="jumpType"/>
      <result column="jump_url" jdbcType="VARCHAR" property="jumpUrl"/>
      <result column="ext_json" jdbcType="LONGVARCHAR" property="extJson"/>
  </resultMap>

  <sql id="Base_Column_List" >
    id,message_id, content_type, content,pic_url,resource_id, create_time,update_time,
     jump_type,
      jump_url,
      serve_id,
      serve_type,
    ext_json
  </sql>

  <insert id="batchInsert" parameterType="com.pcloud.book.cultivate.entity.CultivateNotifyItem" useGeneratedKeys="true" keyProperty="id">
    insert into cultivate_notify_item
    (
      message_id,
      content_type,
      content,
      pic_url,
      resource_id,
      create_time,
      update_time,
      jump_type,
      jump_url,
      serve_id,
      serve_type,
      ext_json
      )
    values
      <foreach collection="list" item="item" index="index" separator=",">
     (
      #{item.messageId},
      #{item.contentType},
      #{item.content},
      #{item.picUrl},
      #{item.resourceId},
      NOW(),
      NOW(),
          #{item.jumpType},
          #{item.jumpUrl},
          #{item.serveId},
          #{item.serveType},
      #{item.extJson}
      )
      </foreach>
  </insert>

  <select id="getNotifyItemsByMessageId" resultMap="BaseResultMap">
    select <include refid="Base_Column_List"/> from cultivate_notify_item where message_id=#{messageId}
  </select>

  <select id="getByMessageIds" parameterType="map" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from cultivate_notify_item
    where message_id in
    <foreach collection="messageIds" open="(" close=")" separator="," item="item">
      #{item}
    </foreach>
  </select>

</mapper>