<?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.book.dao.impl.BookAdviserErpDaoImpl">

	<resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.BookAdviserErp">
		<result column="BOOK_ADVISER_ERP_ID" property="bookAdviserErpId" jdbcType="BIGINT"/>
		<result column="BOOK_ID" property="bookId" jdbcType="BIGINT"/>
		<result column="ADVISER_ID" property="adviserId" jdbcType="BIGINT"/>
		<result column="CHANNEL_ID" property="channelId" jdbcType="BIGINT"/>
		<result column="TEMPLET_ID" property="templetId" jdbcType="BIGINT"/>
		<result column="CREATED_USER" property="createdUser" jdbcType="BIGINT"/>
		<result column="CREATED_DATE" property="createdDate" jdbcType="TIMESTAMP"/>
		<result column="LAST_MODIFIED_DATE" property="lastModifiedDate" jdbcType="TIMESTAMP"/>
		<result column="VERSION" property="version" jdbcType="BIGINT"/>
		<result column="IS_MAIN_EDITOR" property="isMainEditor" jdbcType="BOOLEAN"/>
		<result column="IS_DELETE" property="isDelete" jdbcType="BOOLEAN"/>
		<result column="SECOND_TEMPLET_ID" property="secondTempletId" jdbcType="BIGINT"/>
		<result column="GRA_LABEL_ID" property="graLabelId" jdbcType="INTEGER"/>
		<result column="SUB_LABEL_ID" property="subLabelId" jdbcType="INTEGER"/>
		<result column="VER_LABEL_ID" property="verLabelId" jdbcType="INTEGER"/>
		<result column="AREA_LABEL_ID" property="areaLabelId" jdbcType="INTEGER"/>
		<result column="IS_PRINT" property="isPrint" jdbcType="BOOLEAN"/>
		<result column="pro_label_id" property="proLabelId" jdbcType="INTEGER"/>
		<result column="dep_label_id" property="depLabelId" jdbcType="INTEGER"/>
		<result column="pur_label_id" property="purLabelId" jdbcType="INTEGER"/>
		<result column="is_open_robot_process" property="isOpenRobotProcess" jdbcType="INTEGER"/>
		<result column="vol_label_id" property="volLabelId" jdbcType="INTEGER"/>
	</resultMap>

	<sql id="Base_Column_List">
        BOOK_ADVISER_ERP_ID, BOOK_ID, ADVISER_ID, CHANNEL_ID, TEMPLET_ID, CREATED_USER, CREATED_DATE, LAST_MODIFIED_DATE,
        VERSION, IS_MAIN_EDITOR, IS_DELETE, SECOND_TEMPLET_ID, GRA_LABEL_ID, SUB_LABEL_ID, VER_LABEL_ID, AREA_LABEL_ID,
        IS_PRINT, pro_label_id, dep_label_id, pur_label_id, is_open_robot_process, vol_label_id
    </sql>

	<select id="getByBookId" resultMap="BaseResultMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM book_adviser_erp
		WHERE BOOK_ID = #{bookId}
	</select>

	<!-- 新增书籍和编辑关联信息-->
	<insert id="insert" parameterType="com.pcloud.book.book.entity.BookAdviserErp" useGeneratedKeys="true" keyProperty="bookAdviserErpId" flushCache="true">
		INSERT INTO BOOK_ADVISER_ERP (
			BOOK_ID, ADVISER_ID, CHANNEL_ID, CREATED_USER, CREATED_DATE,IS_MAIN_EDITOR, TEMPLET_ID, SECOND_TEMPLET_ID,
			GRA_LABEL_ID,SUB_LABEL_ID,VER_LABEL_ID,AREA_LABEL_ID,pro_label_id, dep_label_id,pur_label_id,is_open_robot_process,
		vol_label_id
		)
		VALUES (
			#{bookId, jdbcType=VARCHAR}, #{adviserId, jdbcType=VARCHAR}, #{channelId, jdbcType=VARCHAR}, 
			#{adviserId, jdbcType=BIGINT}, NOW(),#{isMainEditor, jdbcType=BIT},#{templetId, jdbcType=BIGINT},
			#{secondTempletId, jdbcType=BIGINT},#{graLabelId, jdbcType=BIGINT},#{subLabelId, jdbcType=BIGINT},
			#{verLabelId, jdbcType=BIGINT},#{areaLabelId, jdbcType=BIGINT},#{proLabelId,jdbcType=BIGINT},
			#{depLabelId,jdbcType=BIGINT},#{purLabelId,jdbcType=BIGINT},#{isOpenRobotProcess,jdbcType=INTEGER},
		#{volLabelId}
		)
	</insert>

</mapper>
