<?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.qmth.paper.library.business.mapper.PictureManageMapper">
    <select id="pageData" resultType="com.qmth.paper.library.business.bean.result.PictureManageDetailResult">
        SELECT
        es.id studentId,
        es.exam_id examId,
        es.student_name studentName,
        es.student_code studentCode,
        bs.NAME semesterName,
        ea.NAME examName,
        es.course_code courseCode,
        es.course_name courseName,
        es.teacher,
        es.teach_class teachClass,
        es.college_name collegeName,
        es.major_name majorName,
        es.class_name className,
        es.exam_room examRoom,
        es.score,
        es.remark,
        es.bind_count bindCount
        FROM
        exam_student es
        left join basic_exam ea on es.exam_id = ea.id
        left join basic_semester bs on es.semester_id = bs.id
        WHERE es.bind_count>0
        <if test="semesterId != null">
            AND bs.id = #{semesterId}
        </if>
        <if test="examId != null">
            AND ea.id = #{examId}
        </if>
        <if test="courseCode != null and courseCode != ''">
            AND es.course_code = #{courseCode}
        </if>
        <if test="collegeName != null and collegeName != ''">
            AND es.college_name = #{collegeName}
        </if>
        <if test="majorName != null and majorName != ''">
            AND es.major_name = #{majorName}
        </if>
        <if test="className != null and className != ''">
            AND es.class_name = #{className}
        </if>
        <if test="teacher != null and teacher != ''">
            and es.teacher like concat(#{teacher},'%')
        </if>
        <if test="teachClass != null and teachClass != ''">
            and es.teach_class like concat(#{teachClass},'%')
        </if>
        <if test="param != null and param != ''">
            and (es.student_name like concat(#{param},'%') or es.student_code like concat(#{param},'%'))
        </if>
        <if test="startStudentCode != null and startStudentCode != ''">
            and es.student_code &gt;= #{startStudentCode}
        </if>
        <if test="endStudentCode != null and endStudentCode != ''">
            and es.student_code &lt;= #{endStudentCode}
        </if>
        <if test="pictureSymbol != null and pictureSymbol !='' and pictureCount != null">
            <if test="pictureSymbol == 'GREAT_THEN'">
                and es.bind_count > #{pictureCount}
            </if>
            <if test="pictureSymbol == 'EQUAL'">
                and es.bind_count = #{pictureCount}
            </if>
            <if test="pictureSymbol == 'LESS_THEN'">
                and es.bind_count <![CDATA[< #{pictureCount} ]]>
            </if>
            <if test="pictureSymbol == 'NOT_EQUAL'">
                and es.bind_count != #{pictureCount}
            </if>
        </if>
        order by es.student_code
    </select>
    <select id="pageDataByStudentIds" resultType="com.qmth.paper.library.business.bean.result.PictureManageDetailResult">
        SELECT
            es.id studentId,
            es.exam_id examId,
            es.student_name studentName,
            es.student_code studentCode,
            bs.NAME semesterName,
            ea.NAME examName,
            es.course_code courseCode,
            es.course_name courseName,
            es.teacher,
            es.teach_class teachClass,
            es.college_name collegeName,
            es.major_name majorName,
            es.class_name className,
            es.exam_room examRoom,
            es.score,
            es.remark,
            es.bind_count bindCount
        FROM
            exam_student es
            left join basic_exam ea on es.exam_id = ea.id
            left join basic_semester bs on es.semester_id = bs.id
        WHERE es.bind_count>0
        AND es.id in
        <foreach collection="studentIds" separator="," open="(" close=")" item="studentId">
            #{studentId}
        </foreach>
        order by es.student_code
    </select>

</mapper>