<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.book.dao.impl.QrcodeSceneErpDaoImpl">

	<resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.QrcodeSceneErp">
		<id column="SCENE_ERP_ID" property="sceneErpId" jdbcType="BIGINT" />
		<result column="MATERIAL_LIB_ID" property="materialLibId" jdbcType="BIGINT" />
		<result column="ADVISER_BOOK_ID" property="adviserBookId" jdbcType="BIGINT" />
		<result column="SCENE_NAME" property="sceneName" jdbcType="VARCHAR" />
		<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
		<result column="QRCODE_URL" property="qrcodeUrl" jdbcType="VARCHAR" />
		<result column="QRCODE_TYPE" property="qrcodeType" jdbcType="VARCHAR" />
		<result column="SCENE_CODE" property="sceneCode" jdbcType="VARCHAR" />
		<result column="IS_HAVE_PROVINCE" property="haveProvinceMessage" jdbcType="BIGINT" />
		<result column="CHANNEL_PARTY_ID" property="channelPartyId"	jdbcType="BIGINT" />
		<result column="IS_DELETE" property="isDelete" jdbcType="VARCHAR" />
		<result column="IS_DELETE_RECYCLE_BIN" property="isDeleteRecycleBin" jdbcType="VARCHAR"/>
		<result column="ACCOUNT_SETTING_ID" property="accountSettingId"	jdbcType="BIGINT" />
		<result column="PURPOSE_TYPE" property="purposeType" jdbcType="VARCHAR" />
		<result column="CREATED_BY_USER_LOGIN" property="createdByUserLogin" jdbcType="BIGINT" />
		<result column="CREATED_USER_ROLE" property="createdUserRole" jdbcType="VARCHAR" />
		<result column="CREATED_DATE" property="createdDate" jdbcType="TIMESTAMP" />
		<result column="LAST_MODIFIED_BY_USER_LOGIN" property="lastModifiedByUserLogin"	jdbcType="BIGINT" />
		<result column="LAST_MODIFIED_DATE" property="lastModifiedDate"	jdbcType="TIMESTAMP" />
		<result column="VERSION" property="version" jdbcType="INTEGER" />
		<result column="CLIENT_CODE" property="clientCode" jdbcType="BIGINT" />
		<result column="AUDIT_STATE" property="auditState" jdbcType="VARCHAR" />
		<result column="AUDIT_USER" property="auditUser" jdbcType="VARCHAR" />
		<result column="AUDIT_DATE" property="auditDate" jdbcType="TIMESTAMP" />
		<result column="AUDIT_REASON" property="auditReason" jdbcType="VARCHAR" />
		<!--<result column="COVER_IMG" property="coverImg" jdbcType="VARCHAR"/>-->
		<result column="BOOK_NAME" property="bookName" jdbcType="VARCHAR" />
		<result column="AUDIT_SUBMIT_DATE" property="auditSubmitDate" jdbcType="TIMESTAMP" />
		<result column="location_page_num" property="locationPageNum" jdbcType="INTEGER" />
		<result column="LOCATION_ID" property="locationId" jdbcType="BIGINT"/>
		<result column="pro_label_id" property="proLabelId" jdbcType="BIGINT"/>
		<result column="dep_label_id" property="depLabelId" jdbcType="BIGINT"/>
		<result column="pur_label_id" property="purLabelId" jdbcType="BIGINT"/>
	</resultMap>

	<sql id="Base_Column_List">
		SCENE_ERP_ID,  MATERIAL_LIB_ID, SCENE_NAME, DESCRIPTION,SCENE_CODE,ADVISER_BOOK_ID,QRCODE_URL,IS_DELETE,
		IS_DELETE_RECYCLE_BIN,PURPOSE_TYPE,CHANNEL_PARTY_ID,ACCOUNT_SETTING_ID,CREATED_BY_USER_LOGIN,
		CREATED_USER_ROLE,VERSION,IS_HAVE_PROVINCE,CLIENT_CODE,AUDIT_STATE, location_page_num, LOCATION_ID,
		pro_label_id, dep_label_id, pur_label_id
	</sql>

	<!-- 根据场景id查询二维码场景基本信息 -->
	<select id="getByBookId" resultMap="BaseResultMap" parameterType="java.lang.Long">
		SELECT
	   		<include refid="Base_Column_List" />
	    FROM QRCODE_SCENE_ERP
		WHERE book_id = #{bookId}
	</select>

	<!-- 插入二维码场景信息 -->
	<insert id="insert" parameterType="com.pcloud.book.book.entity.QrcodeSceneErp" useGeneratedKeys="true" keyProperty="sceneErpId">
		INSERT INTO qrcode_scene_erp(
		SCENE_CODE,	BOOK_ID,ADVISER_BOOK_ID,BOOK_NAME,SCENE_NAME,QRCODE_URL,DESCRIPTION,
		CHANNEL_PARTY_ID, ACCOUNT_SETTING_ID, URL, ADVISER_ID, PURPOSE_TYPE, QRCODE_TYPE,
		TEMPLET_ID, CLIENT_CODE, CREATED_BY_USER_LOGIN, CREATED_DATE, VERSION, is_open_app,
		location_page_num, LOCATION_ID, pro_label_id, dep_label_id, pur_label_id
		) VALUES (
		#{sceneCode, jdbcType=VARCHAR},	#{bookId, jdbcType=BIGINT},	#{adviserBookId, jdbcType=BIGINT},#{bookName, jdbcType=VARCHAR},#{sceneName, jdbcType=VARCHAR},	#{qrcodeUrl, jdbcType=VARCHAR},	#{description, jdbcType=VARCHAR},
		#{channelPartyId, jdbcType=BIGINT},	#{accountSettingId, jdbcType=BIGINT},#{url, jdbcType=VARCHAR},#{adviserId, jdbcType=BIGINT},#{purposeType, jdbcType=VARCHAR},#{qrcodeType, jdbcType=VARCHAR},
		#{templetId, jdbcType=BIGINT}, #{clientCode, jdbcType=BOOLEAN},	#{createdByUserLogin, jdbcType=BIGINT},NOW(),1, #{isOpenApp, jdbcType=BOOLEAN},
		#{locationPageNum}, #{locationId}, #{proLabelId}, #{depLabelId}, #{purLabelId}
		)
	</insert>

</mapper>
