<?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.ym.mec.biz.dal.dao.MusicGroupStudentClassAdjustDao">
	
	<resultMap type="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" id="MusicGroupStudentClassAdjust">
		<result column="id_" property="id" />
		<result column="music_group_id_" property="musicGroupId" />
		<result column="batch_no_" property="batchNo" />
		<result column="new_class_group_json_" property="newClassGroupJson" />
		<result column="class_group_ids_" property="classGroupIds" />
		<result column="student_ids_" property="studentIds" />
		<result column="class_course_minute_" property="classCourseMinute" />
		<result column="master_class_course_times_" property="masterClassCourseTimes" />
		<result column="master_total_price_" property="masterTotalPrice" />
		<result column="default_course_type_minute_" property="defaultCourseTypeMinute" />
		<result column="all_lock_course_ids_" property="allLockCourseIds" />
		<result column="sub_lock_course_ids_" property="subLockCourseIds" />
		<result column="student_payment_ids_" property="studentPaymentIds" />
		<result column="class_group_students_" property="classGroupStudents" />
		<result column="operator_id_" property="operatorId" />
		<result column="master_class_group_id_" property="masterClassGroupId" />
		<result column="create_time_" property="createTime" />
		<result column="update_time_" property="updateTime" />
        <result column="tenant_id_" property="tenantId"/>
	</resultMap>
	
	<!-- 根据主键查询一条记录 -->
	<select id="get" resultMap="MusicGroupStudentClassAdjust" >
		SELECT * FROM music_group_student_class_adjust WHERE id_ = #{id} 
	</select>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="MusicGroupStudentClassAdjust">
		SELECT * FROM music_group_student_class_adjust where tenant_id_ = #{tenantId} ORDER BY id_
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		INSERT INTO music_group_student_class_adjust (music_group_id_,batch_no_,new_class_group_json_,
		class_group_ids_,student_ids_,class_course_minute_,all_lock_course_ids_,sub_lock_course_ids_,
		operator_id_,student_payment_ids_,class_group_students_,default_course_type_minute_,master_class_group_id_,master_class_course_times_,master_total_price_,create_time_,update_time_,tenant_id_)
		VALUES(#{musicGroupId},#{batchNo},#{newClassGroupJson},#{classGroupIds},#{studentIds},
		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{operatorId},#{studentPaymentIds},#{classGroupStudents},
			   #{defaultCourseTypeMinute},#{masterClassGroupId},#{masterClassCourseTimes},#{masterTotalPrice},NOW(),NOW(),#{tenantId})
	</insert>
	
	<!-- 根据主键查询一条记录 -->
	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust">
		UPDATE music_group_student_class_adjust <set>
		<if test="masterTotalPrice != null">
			master_total_price_ = #{masterTotalPrice},
		</if>
		<if test="masterClassCourseTimes != null">
			master_class_course_times_ = #{masterClassCourseTimes},
		</if>
		<if test="masterClassGroupId != null">
			master_class_group_id_ = #{masterClassGroupId},
		</if>
		<if test="defaultCourseTypeMinute != null">
			default_course_type_minute_ = #{defaultCourseTypeMinute},
		</if>
		<if test="classGroupStudents != null">
			class_group_students_ = #{classGroupStudents},
		</if>
		<if test="studentPaymentIds != null">
			student_payment_ids_ = #{studentPaymentIds},
		</if>
		<if test="allLockCourseIds != null">
		all_lock_course_ids_ = #{allLockCourseIds},
		</if>
		<if test="subLockCourseIds != null">
		sub_lock_course_ids_ = #{subLockCourseIds},
		</if>
		<if test="classCourseMinute != null">
		class_course_minute_ = #{classCourseMinute},
		</if>
		<if test="newClassGroupJson != null">
		new_class_group_json_ = #{newClassGroupJson},
		</if>
		<if test="batchNo != null">
		batch_no_ = #{batchNo},
		</if>
		<if test="studentIds != null">
		student_ids_ = #{studentIds},
		</if>
		<if test="classGroupIds != null">
		class_group_ids_ = #{classGroupIds},
		</if>
		<if test="musicGroupId != null">
		music_group_id_ = #{musicGroupId},
		</if>
		update_time_ = NOW()
		</set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
	</update>
	
	<!-- 根据主键删除一条记录 -->
	<delete id="delete" >
		DELETE FROM music_group_student_class_adjust WHERE id_ = #{id} 
	</delete>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="MusicGroupStudentClassAdjust" parameterType="map">
		SELECT * FROM music_group_student_class_adjust where tenant_id_ = #{tenantId} ORDER BY id_ <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM music_group_student_class_adjust where tenant_id_ = #{tenantId}
	</select>
    <select id="findByBatchNo" resultMap="MusicGroupStudentClassAdjust">
		SELECT * FROM music_group_student_class_adjust WHERE FIND_IN_SET(#{batchNo},batch_no_)
	</select>
</mapper>
