luohairen
2024-11-14 247cb86585a1d1894596ed18a6c93efecb992946
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?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.ycl.jxkg.mapper.QuestionAnswerRecordMapper">
    <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.QuestionAnswerRecord">
        <id property="id" column="id" />
        <result property="userId" column="user_id" />
        <result property="examId" column="exam_id" />
        <result property="paperId" column="paper_id" />
        <result property="questionId" column="question_id" />
        <result property="doRight" column="do_right" />
        <result property="userAnswer" column="user_answer" />
        <result property="score" column="score" />
        <result property="questionType" column="question_type" />
    </resultMap>
 
    <resultMap id="WrongResultMap" type="com.ycl.jxkg.domain.vo.student.wrong.WrongResponseVO">
        <result property="examId" column="exam_id" />
        <result property="questionId" column="question_id" />
        <result property="title" column="title" />
        <result property="questionType" column="question_type" />
        <result property="difficult" column="difficult" />
        <result property="score" column="score" />
        <result property="examName" column="exam_name" />
    </resultMap>
 
 
    <select id="selectWrongQuestion" resultMap="WrongResultMap">
        SELECT
            e.id AS exam_id,
            q.id AS question_id,
            q.title,
            q.question_type,
            q.difficult,
            qar.score,
            e.exam_name
        FROM t_question_answer_record qar
            LEFT JOIN t_question q ON q.id = qar.question_id
            LEFT JOIN t_exam e ON e.id = qar.exam_id
        <where>
            qar.user_id = #{wrongRequestVo.userId}
            and do_right = 0
            <if test="wrongRequestVo.title != null and wrongRequestVo.title != ''">
                and q.title like concat('%',#{wrongRequestVo.title},'%')
            </if>
            <if test="wrongRequestVo.questionType != null">
                and q.question_type = #{wrongRequestVo.questionType}
            </if>
            <if test="wrongRequestVo.examName != null and wrongRequestVo.examName != ''">
                and e.exam_name like concat('%',#{wrongRequestVo.examName},'%')
            </if>
        </where>
    </select>
</mapper>