<?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.CourseScheduleModifyLogDao">

	<resultMap type="com.ym.mec.biz.dal.entity.CourseScheduleModifyLog"
		id="CourseScheduleModifyLog">
		<result column="id_" property="id" />
		<result column="course_schedule_id_" property="courseScheduleId" />
		<result column="operator_id_" property="operatorId" />
		<result column="previous_course_schedule_" property="previousCourseSchedule" />
		<result column="current_course_schedule_" property="currentCourseSchedule" />
		<result column="create_time_" property="createTime" />
	</resultMap>


	<!-- 全查询 -->
	<select id="findAll" resultMap="CourseScheduleModifyLog">
		SELECT * FROM
		course_schedule_modify_log
		<include refid="queryPageSql"/>
		ORDER BY id_ ASC
	</select>

	<!-- 向数据库增加一条记录 -->
	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleModifyLog"
		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
			AS ID FROM DUAL </selectKey> -->
		INSERT INTO course_schedule_modify_log
		(id_,course_schedule_id_,operator_id_,previous_course_schedule_,current_course_schedule_,create_time_)
		VALUES(#{id},#{courseScheduleId},#{operatorId},#{previousCourseSchedule},#{currentCourseSchedule},#{createTime})
	</insert>
    <insert id="batchInsert">
		INSERT INTO course_schedule_modify_log
		(course_schedule_id_,operator_id_,previous_course_schedule_,current_course_schedule_,create_time_)
		VALUES
		<foreach collection="scheduleModifyLogs" item="item" separator=",">
			(#{item.courseScheduleId},#{item.operatorId},#{item.previousCourseSchedule},#{item.currentCourseSchedule},#{item.createTime})
		</foreach>
	</insert>
	<sql id="queryPageSql">
		<where>
			<if test="courseScheduleId != null">
				AND course_schedule_id_ = #{courseScheduleId}
			</if>
		</where>
	</sql>

    <!-- 分页查询 -->
	<select id="queryPage" resultMap="CourseScheduleModifyLog"
		parameterType="map">
		SELECT * FROM course_schedule_modify_log
		<include refid="queryPageSql"/>
		<include refid="global.limit" />
	</select>

	<!-- 查询当前表的总记录数 -->
	<select id="queryCount" resultType="int">
		SELECT COUNT(*) FROM
		course_schedule_modify_log
		<include refid="queryPageSql"/>
	</select>
</mapper>
