<?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.yonge.cooleshow.biz.dal.dao.MusicSheetPurchaseRecordDao">

	<resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.MusicSheetPurchaseRecord">
	     <id column="id_" jdbcType="BIGINT" property="id" />
		 <result column="music_sheet_id_" jdbcType="BIGINT" property="musicSheetId" />
		 <result column="teacher_id_" jdbcType="BIGINT" property="teacherId" />
		 <result column="order_no_" jdbcType="VARCHAR" property="orderNo" />
		 <result column="client_type_" jdbcType="VARCHAR" property="clientType" />
		 <result column="student_id_" jdbcType="BIGINT" property="studentId" />
		 <result column="purchase_time_" jdbcType="TIMESTAMP" property="purchaseTime" />
		 <result column="purchase_price_" jdbcType="DECIMAL" property="purchasePrice" />
		 <result column="order_status_" jdbcType="TINYINT" property="orderStatus" />
	</resultMap>

	<sql id="Base_Column_List">
		id_, music_sheet_id_, teacher_id_, order_no_, student_id_, purchase_time_, purchase_price_, order_status_,client_type_
	</sql>

	<update id="updateCourseMusicAlbum">
		UPDATE music_sheet_purchase_record
		SET
		music_sheet_id_ = CASE course_music_album_id_
		<foreach collection="items" item="item">
			WHEN #{item.id} THEN #{item.musicAlbumId}
		</foreach>
		END,
		purchase_type_ = CASE course_music_album_id_
		<foreach collection="items" item="item">
			WHEN #{item.id} THEN #{item.relationType}
		</foreach>
		END
		WHERE
		course_music_album_id_ IN
		<foreach collection="items" item="item" separator="," open="(" close=")">
			#{item.id}
		</foreach>
    </update>
</mapper>