<?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.xjrsoft.module.xycxedu.mapper.ExamSubjectScoreMappper">
    <select id="getUserIdByIdNumber" parameterType="java.lang.String" resultType="java.lang.Long">
        SELECT t1.id FROM xjr_user t1
        INNER JOIN base_student t2 ON t1.id = t2.user_id
        WHERE t1.credential_number = #{idNumber}
    </select>

    <select id="getPage" parameterType="com.xjrsoft.module.xycxedu.dto.ExamSubjectScoreDto" resultType="com.xjrsoft.module.xycxedu.vo.ExamSubjectScorePageVo">
        SELECT t4.name AS semester_name,t2.milexamname,t1.coursename,t1.score,t1.grade_ranking FROM exam_subject_score t1
        INNER JOIN xycxedu_exam_list t2 ON t1.milexamid = t2.milexamid
        LEFT JOIN exam_plan t3 ON t3.milexamids LIKE CONCAT('%', t1.milexamid, '%')
        LEFT JOIN base_semester t4 ON t3.semester_id = t4.id
        WHERE t1.delete_mark = 0 AND t1.user_id = #{dto.userId}
        <if test="dto.semesterId != null">
            and t4.id = #{dto.semesterId}
        </if>
        <if test="dto.semesterId != null">
            and t3.id = #{dto.examPlanId}
        </if>
    </select>
</mapper>