<?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="org.dromara.system.mapper.CourseChangeMapper">


    <resultMap type="org.dromara.system.domain.vo.CourseChangeVo" id="CourseChangeResult">
        <result property="id"    column="id"    />
        <result property="applyId"    column="apply_id"    />
        <result property="applyName"    column="apply_name"    />
        <result property="applyTime"    column="apply_time"    />
        <result property="subjectClassId"    column="subject_class_id"    />
        <result property="subjectClass"    column="subject_class"    />
        <result property="subject"    column="subject"    />
        <result property="isNum"    column="is_num"    />
        <result property="subjectTime"    column="subject_time"    />
        <result property="subjectWeek"    column="subject_week"    />
        <result property="bePersonnel"    column="be_personnel"    />
        <result property="bePersonnelId"    column="be_personnel_id"    />
        <result property="beSubject"    column="be_subject"    />
        <result property="beIsNum"    column="be_is_num"    />
        <result property="beSubjectTime"    column="be_subject_time"    />
        <result property="week"    column="week"    />
        <result property="isPass"    column="is_pass"    />
        <result property="content"    column="content"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="auditId"    column="audit_id"    />
        <result property="auditUser"    column="audit_user"    />
        <result property="opinion"    column="opinion"    />
        <result property="schoolId"    column="school_id"    />
        <result property="schoolName"    column="school_name"    />
    </resultMap>

    <sql id="selectCourseChangeVo">
        select id, apply_id, apply_name, apply_time, subject_class_id, subject_class, subject, is_num, subject_time, subject_week, be_personnel, be_personnel_id, be_subject, be_is_num, be_subject_time, week, is_pass, content, create_by, create_time, update_by, update_time, remark, audit_id, audit_user, opinion, school_id, school_name from course_change
    </sql>

    <select id="selectCourseChangeListByEdit" resultMap="CourseChangeResult">
        <include refid="selectCourseChangeVo"/>
        where subject_class_id = #{classId} and is_pass = 2
        and ((date_format(subject_time,'%y%m%d') &gt;= date_format(#{fist},'%y%m%d') and date_format(subject_time,'%y%m%d') &lt;= date_format(#{five},'%y%m%d'))
        or (date_format(be_subject_time,'%y%m%d') &gt;= date_format(#{fist},'%y%m%d') and date_format(be_subject_time,'%y%m%d') &lt;= date_format(#{five},'%y%m%d')))
    </select>

    <select id="selectCourseChangeListByTime" resultMap="CourseChangeResult">
        <include refid="selectCourseChangeVo"/>
        where date_format(create_time,'%Y%m') = date_format(#{monthFirst},'%Y%m')
        <if test="userId != null and userId != 0">
            and apply_id = #{userId}
        </if>
        <if test="deptId != null and deptId != 0">
            and school_id = #{deptId}
        </if>
    </select>
</mapper>
