<?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.BookDefendantDaoImpl">

	<!-- 书籍申诉实体DTO -->
	<resultMap id="BookDefendantMap" type="bookDefendant">
		<id column="BOOK_DEFENDANT_ID" property="bookDefendantId" jdbcType="BIGINT" />
		<result column="BOOK_APPEAL_ID" property="bookAppealId" jdbcType="BIGINT" />
		<result column="ADVISER_ID" property="adviserId" jdbcType="BIGINT" />
		<result column="CHANNEL_ID" property="channelId" jdbcType="BIGINT" />
		<result column="CREATED_DATE" property="createdDate" jdbcType="TIMESTAMP" />
		<result column="IS_MAIN_EDITOR" property="isMainEditor" jdbcType="BIT" />
	</resultMap>
	
	  <!--批量添加申诉方 -->
	<insert id="batchInsert" parameterType="bookDefendant" useGeneratedKeys="true" keyProperty="bookDefendantId">
		insert into BOOK_DEFENDANT
		(
			BOOK_APPEAL_ID, ADVISER_ID,CREATED_DATE,IS_MAIN_EDITOR,CHANNEL_ID
		)
		values
		<foreach collection="list" item="item" index="index" separator=",">
		(
			#{item.bookAppealId,jdbcType=BIGINT}, #{item.adviserId,jdbcType=BIGINT}, 
			#{item.createdDate,jdbcType=TIMESTAMP}, #{item.isMainEditor,jdbcType=BIT},
			#{item.channelId,jdbcType=BIT}
		)
		</foreach>
	</insert>
	<!-- 获取申诉方列表 -->
	<select id="list" resultMap="BookDefendantMap" parameterType="map">
		SELECT 
			BOOK_DEFENDANT_ID, BOOK_APPEAL_ID, CHANNEL_ID, ADVISER_ID,CREATED_DATE,IS_MAIN_EDITOR
		FROM 
			BOOK_DEFENDANT 
		WHERE BOOK_APPEAL_ID = #{bookDefendantId}
	</select>
	
</mapper>