<?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.teachcloud.mark.mapper.MarkProblemHistoryMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.mark.entity.MarkProblemHistory">
        <id column="id" property="id" />
        <result column="exam_id" property="examId" />
        <result column="paper_number" property="paperNumber" />
        <result column="group_number" property="groupNumber" />
        <result column="student_code" property="studentCode" />
        <result column="secret_number" property="secretNumber" />
        <result column="type" property="type" />
        <result column="student_id" property="studentId" />
        <result column="task_id" property="taskId" />
        <result column="status" property="status" />
        <result column="update_user_id" property="updateUserId" />
        <result column="user_id" property="userId" />
        <result column="score_list" property="scoreList" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="remark" property="remark" />
    </resultMap>
    <select id="pageProblem" resultType="com.qmth.teachcloud.mark.dto.mark.manage.MarkProblemDto">
        SELECT
            id,
            task_id taskId,
            student_id studentId,
            group_number groupNumber,
            secret_number secretNumber,
            type,
            status,
            user_id userId,
            update_user_id updateUserId,
            create_time createTime,
            update_time updateTime,
            remark
        FROM
            mark_problem_history
        where
            exam_id = #{examId}
            AND paper_number = #{paperNumber}
            <if test="groupNumber != null">
                AND group_number = #{groupNumber}
            </if>
            <if test="problemType != null and problemType != ''">
                AND type = #{problemType}
            </if>
            <if test="status != null and status != ''">
                AND status = #{status}
            </if>
            <if test="secretNumber != null and secretNumber != ''">
                AND secret_number = #{secretNumber}
            </if>
        ORDER BY status desc, create_time asc
    </select>

</mapper>
