<?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.StudentCourseFeeDetailDao">
	
	<resultMap type="com.ym.mec.biz.dal.entity.StudentCourseFeeDetail" id="StudentCourseFeeDetail">
		<result column="student_registration_id_" property="studentRegistrationId" />
		<result column="amount_" property="amount" />
		<result column="surplus_course_fee_" property="surplusCourseFee" />
		<result column="memo_" property="memo" />
		<result column="operator_" property="operator" />
		<result column="create_time_" property="createTime" />
		<result column="update_time_" property="updateTime" />
        <result column="tenant_id_" property="tenantId"/>
	</resultMap>
	
	<!-- 全查询 -->
	<select id="findAll" resultMap="StudentCourseFeeDetail">
		SELECT * FROM student_course_fee_detail where tenant_id_ = #{tenantId}
	</select>
	
	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCourseFeeDetail" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		INSERT INTO student_course_fee_detail (student_registration_id_,amount_,surplus_course_fee_,memo_,operator_,create_time_,update_time_,tenant_id_)
		VALUES(#{studentRegistrationId},#{amount},#{surplusCourseFee},#{memo},#{operator},NOW(),NOW(),#{tenantId})
	</insert>

	<update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCourseFeeDetail">
		UPDATE student_course_fee_detail
		<set>
			<if test="amount!=null">
				amount_ = #{amount},
			</if>
			<if test="surplusCourseFee!=null">
				surplus_course_fee_ = #{surplusCourseFee}
			</if>
			<if test="memo!=null">
				memo_ = #{memo}
			</if>
			<if test="operator!=null">
				operator_ = #{operator}
			</if>
			update_time_ = NOW()
		</set>
		WHERE student_registration_id_ = #{studentRegistrationId}
	</update>
	
	<!-- 分页查询 -->
	<select id="queryPage" resultMap="StudentCourseFeeDetail" parameterType="map">
		SELECT * FROM student_course_fee_detail where tenant_id_ = #{tenantId} <include refid="global.limit"/>
	</select>
	
	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM student_course_fee_detail where tenant_id_ = #{tenantId}
	</select>

	<insert id="batchInsert">
		INSERT INTO student_course_fee_detail (student_registration_id_,amount_,surplus_course_fee_,memo_,operator_,create_time_,update_time_,tenant_id_)
		VALUES
		<foreach collection="studentCourseFeeDetails" item="item" separator=",">
			(#{item.studentRegistrationId},#{item.amount},#{item.surplusCourseFee},#{item.memo},#{item.operator},NOW(),NOW(),#{item.tenantId})
		</foreach>
    </insert>
</mapper>
