<?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.reading.dao.impl.ReadingInviteDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.reading.entity.ReadingInvite" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="activity_id" property="activityId" jdbcType="BIGINT" />
    <result column="invite_time" property="inviteTime" jdbcType="TIMESTAMP" />
    <result column="invite_type" property="inviteType" jdbcType="BIT" />
    <result column="invite_content" property="inviteContent" jdbcType="VARCHAR" />
    <result column="invite_resource_id" property="inviteResourceId" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="create_user" property="createUser" jdbcType="BIGINT" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, activity_id, invite_time, invite_type, invite_content, invite_resource_id, create_time, create_user
  </sql>

  <insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
    insert into reading_invite (activity_id, invite_time,
    invite_type, invite_content, invite_resource_id, create_time,
    create_user)
    values
    <foreach collection="list" item="item" index="index" separator="," >
      (#{item.activityId,jdbcType=BIGINT}, #{item.inviteTime,jdbcType=TIMESTAMP},
      #{item.inviteType,jdbcType=BIT}, #{item.inviteContent,jdbcType=VARCHAR}, #{item.inviteResourceId}, NOW(),
      #{item.createUser,jdbcType=BIGINT})
    </foreach>
  </insert>

  <select id="getByActivityId" parameterType="long" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List"/>
    FROM reading_invite
    WHERE activity_id = #{activityId}
  </select>

  <delete id="deleteByActivityId" parameterType="long">
    DELETE
    FROM reading_invite
    WHERE activity_id = #{activityId}
  </delete>

</mapper>