<?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.yida.data.school.transaction.mapper.EduStudentApplyMapper">
  <select id="getStudentApplyStatus"
    resultType="com.yida.data.common.core.entity.apply.EduStudentApply">
    select *
    from edu_student_apply
    where student_id = #{studentId}
      and apply_code = #{applyCode}
    order by end_time desc
  </select>
  <select id="listStudentApply" resultType="com.yida.data.common.core.entity.apply.EduStudentApply">
    SELECT esa.*,
    CONCAT(
    school.DEPT_NAME,
    '/',
    section.DEPT_NAME,
    '/',
    campus.DEPT_NAME,
    '/',
    grade.DEPT_NAME,
    '/',
    class.DEPT_NAME
    ) deptName,es.stu_name studentName
    from edu_student_apply esa
    LEFT JOIN edu_student es ON esa.student_id = es.id
    LEFT JOIN t_dept school ON es.school_id = school.DEPT_ID
    LEFT JOIN edu_user_dept section ON es.section_id = section.DEPT_ID
    LEFT JOIN edu_user_dept campus ON es.campus_id = campus.DEPT_ID
    LEFT JOIN edu_user_dept grade ON es.grade_id = grade.DEPT_ID
    LEFT JOIN edu_user_dept class ON es.class_id = class.DEPT_ID
    WHERE esa.del_flag = 0
    <if test="studentName!=null and studentName!=''">
      and es.stu_name LIKE CONCAT('%',#{studentName},'%')
    </if>
    <if test="studentNumber!=null and studentNumber!=''">
      and es.stu_number LIKE CONCAT('%',#{studentNumber},'%')
    </if>
    <if test="schoolId!=null">
      and es.school_id LIKE CONCAT('%',#{schoolId},'%')
    </if>
    <if test="sectionId!=null">
      and es.section_id LIKE CONCAT('%',#{sectionId},'%')
    </if>
    <if test="campusId!=null">
      and es.campus_id LIKE CONCAT('%',#{campusId},'%')
    </if>
    <if test="gradeId!=null">
      and es.grade_id LIKE CONCAT('%',#{gradeId},'%')
    </if>
    <if test="classId!=null">
      and es.class_id LIKE CONCAT('%',#{classId},'%')
    </if>
    order by create_date desc
  </select>
</mapper>