<?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.appeal.dao.impl.BookAppealResultDaoImpl">

	<!-- 书籍申诉结果实体DTO -->
	<resultMap id="BookAppealResultMap" type="bookAppealResultDto">
		<id column="id" property="id" jdbcType="BIGINT" />
		<result column="book_id" property="bookId" jdbcType="BIGINT" />
		<result column="book_appeal_id" property="bookAppealId" jdbcType="BIGINT" />
		<result column="CHANNEL_ID" property="channelId" jdbcType="BIGINT" />
		<result column="ADVISER_ID" property="adviserId" jdbcType="BIGINT" />
		<result column="BOOK_CREATED_DATE" property="bookCreatedDate" jdbcType="TIMESTAMP" />
		<result column="CREATED_DATE" property="createdDate" jdbcType="TIMESTAMP" />
		<result column="IS_MAIN_EDITOR" property="isMainEditor" jdbcType="BIT" />
	</resultMap>
	
	  <!--批量添加申诉方 -->
	<insert id="batchInsert" parameterType="bookAppealResult" useGeneratedKeys="true" keyProperty="id">
		insert into BOOK_APPEAL_RESULT
		(
			BOOK_APPEAL_ID, ADVISER_ID, CHANNEL_ID, BOOK_ID, BOOK_CREATED_DATE, CREATED_DATE,IS_MAIN_EDITOR
		)
		values
		<foreach collection="list" item="item" index="index" separator=",">
		(
			#{item.bookAppealId,jdbcType=BIGINT}, #{item.adviserId,jdbcType=BIGINT},
			#{item.channelId,jdbcType=BIGINT}, #{item.bookId,jdbcType=BIGINT}, #{item.bookCreatedDate,jdbcType=TIMESTAMP},
			now(), #{item.isMainEditor,jdbcType=BIT}
		)
		</foreach>
	</insert>

	<!-- 获取申诉结果列表 -->
	<select id="getAppealResult" resultMap="BookAppealResultMap" parameterType="Long">
		SELECT 
			 BOOK_APPEAL_ID, ADVISER_ID, BOOK_ID, CHANNEL_ID, BOOK_CREATED_DATE, CREATED_DATE, IS_MAIN_EDITOR
		FROM 
			BOOK_APPEAL_RESULT
		WHERE BOOK_APPEAL_ID = #{bookAppealId}
	</select>
	
</mapper>