<?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.admin.major.mapper.ScheduleArrangeMapper">
    
    <resultMap type="ScheduleArrange" id="ScheduleArrangeResult">
        <result property="orginId"    column="orgin_id"    />
        <result property="scheduleId"    column="schedule_id"    />
        <result property="scheduleName"    column="schedule_name"    />
        <result property="year"    column="year"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="collegeId"    column="college_id"    />
    </resultMap>

    <sql id="selectScheduleArrangeVo">
        select orgin_id, schedule_id, schedule_name, year, start_date, end_date, status, create_time, update_time, update_user_id, create_user_id, college_id from m_schedule_arrange
    </sql>

    <select id="selectScheduleArrangeList" parameterType="ScheduleArrange" resultMap="ScheduleArrangeResult">
        <include refid="selectScheduleArrangeVo"/>
        <where>  
            <if test="orginId != null  and orginId != ''"> and orgin_id = #{orginId}</if>
            <if test="scheduleId != null "> and schedule_id = #{scheduleId}</if>
            <if test="scheduleName != null  and scheduleName != ''"> and schedule_name like concat('%', #{scheduleName}, '%')</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="updateUserId != null  and updateUserId != ''"> and update_user_id = #{updateUserId}</if>
            <if test="createUserId != null  and createUserId != ''"> and create_user_id = #{createUserId}</if>
            <if test="collegeId != null "> and college_id = #{collegeId}</if>
        </where>
    </select>
    
    <select id="selectScheduleArrangeByOrginId" parameterType="String" resultMap="ScheduleArrangeResult">
        <include refid="selectScheduleArrangeVo"/>
        where orgin_id = #{orginId}
    </select>
        
    <insert id="insertScheduleArrange" parameterType="ScheduleArrange">
        insert into m_schedule_arrange
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orginId != null">orgin_id,</if>
            <if test="scheduleId != null">schedule_id,</if>
            <if test="scheduleName != null">schedule_name,</if>
            <if test="year != null">year,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="collegeId != null">college_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orginId != null">#{orginId},</if>
            <if test="scheduleId != null">#{scheduleId},</if>
            <if test="scheduleName != null">#{scheduleName},</if>
            <if test="year != null">#{year},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="collegeId != null">#{collegeId},</if>
         </trim>
    </insert>

    <update id="updateScheduleArrange" parameterType="ScheduleArrange">
        update m_schedule_arrange
        <trim prefix="SET" suffixOverrides=",">
            <if test="scheduleId != null">schedule_id = #{scheduleId},</if>
            <if test="scheduleName != null">schedule_name = #{scheduleName},</if>
            <if test="year != null">year = #{year},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="collegeId != null">college_id = #{collegeId},</if>
        </trim>
        where orgin_id = #{orginId}
    </update>

    <delete id="deleteScheduleArrangeByOrginId" parameterType="String">
        delete from m_schedule_arrange where orgin_id = #{orginId}
    </delete>

    <delete id="deleteScheduleArrangeByOrginIds" parameterType="String">
        delete from m_schedule_arrange where orgin_id in 
        <foreach item="orginId" collection="array" open="(" separator="," close=")">
            #{orginId}
        </foreach>
    </delete>
</mapper>