<?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" />
  </resultMap>

  <sql id="Base_Column_List" >
    id,message_id, content_type, content,pic_url,resource_id, create_time,update_time
  </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
      )
    values
      <foreach collection="list" item="item" index="index" separator=",">
     (
      #{item.messageId},
      #{item.contentType},
      #{item.content},
      #{item.picUrl},
      #{item.resourceId},
      NOW(),
      NOW()
      )
      </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>