|
@@ -0,0 +1,264 @@
|
|
|
+<?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.zhongzheng.modules.user.mapper.UserMockRecordMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.zhongzheng.modules.user.domain.UserMockRecord" id="UserMockRecordResult">
|
|
|
+ <result property="recordId" column="record_id"/>
|
|
|
+ <result property="examId" column="exam_id"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="reportStatus" column="report_status"/>
|
|
|
+ <result property="performance" column="performance"/>
|
|
|
+ <result property="historyExamJson" column="history_exam_json"/>
|
|
|
+ <result property="totalQuestionNum" column="total_question_num"/>
|
|
|
+ <result property="rightQuestionNum" column="right_question_num"/>
|
|
|
+ <result property="doQuestionNum" column="do_question_num"/>
|
|
|
+ <result property="moduleExamId" column="module_exam_id"/>
|
|
|
+ <result property="chapterExamId" column="chapter_exam_id"/>
|
|
|
+ <result property="doTime" column="do_time"/>
|
|
|
+ <result property="examTime" column="exam_time"/>
|
|
|
+ <result property="totalScore" column="total_score"/>
|
|
|
+ <result property="doQuestionIds" column="do_question_ids"/>
|
|
|
+ <result property="rightQuestionIds" column="right_question_ids"/>
|
|
|
+ <result property="score" column="score"/>
|
|
|
+ <result property="allQuestionNum" column="all_question_num"/>
|
|
|
+ <result property="lessQuestionNum" column="less_question_num"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap type="com.zhongzheng.modules.user.vo.UserMockRecordVo" id="UserMockRecordVoResult">
|
|
|
+ <result property="recordId" column="record_id"/>
|
|
|
+ <result property="examId" column="exam_id"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="reportStatus" column="report_status"/>
|
|
|
+ <result property="performance" column="performance"/>
|
|
|
+ <result property="historyExamJson" column="history_exam_json"/>
|
|
|
+ <result property="totalQuestionNum" column="total_question_num"/>
|
|
|
+ <result property="rightQuestionNum" column="right_question_num"/>
|
|
|
+ <result property="doQuestionNum" column="do_question_num"/>
|
|
|
+ <result property="moduleExamId" column="module_exam_id"/>
|
|
|
+ <result property="chapterExamId" column="chapter_exam_id"/>
|
|
|
+ <result property="doQuestionIds" column="do_question_ids"/>
|
|
|
+ <result property="rightQuestionIds" column="right_question_ids"/>
|
|
|
+ <result property="doType" column="do_type"/>
|
|
|
+ <result property="allQuestionNum" column="all_question_num"/>
|
|
|
+
|
|
|
+ <result property="examName" column="exam_name"/>
|
|
|
+ <result property="paperName" column="paper_name"/>
|
|
|
+ <result property="doTime" column="do_time"/>
|
|
|
+ <result property="examTime" column="exam_time"/>
|
|
|
+ <result property="totalScore" column="total_score"/>
|
|
|
+ <result property="score" column="score"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <resultMap type="com.zhongzheng.modules.user.vo.UserMockWrongRecordVo" id="UserMockRecordQuestionVoResult">
|
|
|
+ <result property="wrongId" column="wrong_id"/>
|
|
|
+ <result property="recordId" column="record_id"/>
|
|
|
+ <result property="questionId" column="question_id"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="examId" column="exam_id"/>
|
|
|
+
|
|
|
+
|
|
|
+ <result property="examName" column="exam_name"/>
|
|
|
+ <result property="wrongQuestionNum" column="wrong_question_num"/>
|
|
|
+ <result property="type" column="type"/>
|
|
|
+ <result property="num" column="num"/>
|
|
|
+
|
|
|
+ <result property="content" column="content"/>
|
|
|
+ <result property="type" column="type"/>
|
|
|
+ <result property="answerQuestion" column="answer_question"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="analysisContent" column="analysis_content"/>
|
|
|
+ <result property="imgUrl" column="img_url"/>
|
|
|
+ <result property="jsonStr" column="json_str"/>
|
|
|
+ <result property="prefixName" column="prefix_name"/>
|
|
|
+ <result property="knowledgeIds" column="knowledge_ids"/>
|
|
|
+ <result property="publishStatus" column="publish_status"/>
|
|
|
+ <result property="code" column="code"/>
|
|
|
+
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <select id="selectList" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordVoResult">
|
|
|
+ SELECT
|
|
|
+ ue.*,
|
|
|
+ e.exam_name,
|
|
|
+ ep.paper_name
|
|
|
+ FROM
|
|
|
+ user_exam_record ue
|
|
|
+ LEFT JOIN exam e ON ue.exam_id = e.exam_id
|
|
|
+ LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
|
|
|
+ WHERE
|
|
|
+ ue.user_id = #{userId}
|
|
|
+ <if test="paperId != null and paperId != ''">
|
|
|
+ AND ep.paper_id = #{paperId}
|
|
|
+ </if>
|
|
|
+ <if test="examId != null and examId != ''">
|
|
|
+ AND ue.exam_id = #{examId}
|
|
|
+ </if>
|
|
|
+ <if test="moduleExamId != null and moduleExamId != ''">
|
|
|
+ AND ue.module_exam_id = #{moduleExamId}
|
|
|
+ </if>
|
|
|
+ <if test="chapterExamId != null and chapterExamId != ''">
|
|
|
+ AND ue.chapter_exam_id = #{chapterExamId}
|
|
|
+ </if>
|
|
|
+ ORDER by ue.record_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectGroupList" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordVoResult">
|
|
|
+ SELECT
|
|
|
+ ue.*,
|
|
|
+ e.exam_name,
|
|
|
+ ep.paper_name
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ ue.exam_id,
|
|
|
+ ue.module_exam_id,
|
|
|
+ ue.chapter_exam_id,
|
|
|
+ MAX( UE.record_id ) record_id
|
|
|
+ FROM
|
|
|
+ user_exam_record ue
|
|
|
+ LEFT JOIN exam e ON ue.exam_id = e.exam_id
|
|
|
+ LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
|
|
|
+ WHERE
|
|
|
+ ue.user_id = #{userId}
|
|
|
+ GROUP BY
|
|
|
+ ue.exam_id,
|
|
|
+ ue.module_exam_id,
|
|
|
+ ue.chapter_exam_id
|
|
|
+ ) t
|
|
|
+ LEFT JOIN user_exam_record ue ON t.record_id = ue.record_id
|
|
|
+ LEFT JOIN exam e ON ue.exam_id = e.exam_id
|
|
|
+ LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
|
|
|
+ WHERE
|
|
|
+ ue.user_id = #{userId}
|
|
|
+ <if test="paperId != null and paperId != ''">
|
|
|
+ AND ep.paper_id = #{paperId}
|
|
|
+ </if>
|
|
|
+ <if test="examId != null and examId != ''">
|
|
|
+ AND ue.exam_id = #{examId}
|
|
|
+ </if>
|
|
|
+ ORDER by ue.record_id DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectDoNum" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ IFNULL( COUNT(*), 0 ) num
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ e.exam_id,
|
|
|
+ q.*
|
|
|
+ FROM
|
|
|
+ ( SELECT exam_id, group_concat( do_question_ids ) AS ids FROM user_exam_record WHERE user_id = #{userId} and do_question_ids is not null and `status` = 1 GROUP BY exam_id ) e
|
|
|
+ LEFT JOIN question q ON FIND_IN_SET( q.question_id, e.ids )) AS eq
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRightNum" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ IFNULL( COUNT( DISTINCT question_id ), 0 ) num
|
|
|
+ FROM
|
|
|
+ question
|
|
|
+ WHERE
|
|
|
+ FIND_IN_SET(
|
|
|
+ question_id,(
|
|
|
+ SELECT
|
|
|
+ group_concat( uer.right_question_ids ) AS ids
|
|
|
+ FROM
|
|
|
+ user_exam_record uer
|
|
|
+ WHERE
|
|
|
+ record_id IN ( SELECT MAX( record_id ) record_id FROM user_exam_record WHERE user_id = #{userId} and `status` = 1 GROUP BY exam_id )))
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectDetail" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordVoResult">
|
|
|
+ SELECT
|
|
|
+ uer.*,
|
|
|
+ e.exam_name
|
|
|
+ FROM
|
|
|
+ user_exam_record uer
|
|
|
+ LEFT JOIN exam e ON uer.exam_id = e.exam_id
|
|
|
+ WHERE
|
|
|
+ uer.record_id = #{recordId}
|
|
|
+ AND uer.user_id = #{userId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectExamList" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordVoResult">
|
|
|
+ SELECT
|
|
|
+ e.exam_id,
|
|
|
+ e.exam_name,
|
|
|
+ e.do_type,
|
|
|
+ uer.total_question_num
|
|
|
+ FROM
|
|
|
+ ( SELECT
|
|
|
+ COUNT( question_id ) total_question_num,
|
|
|
+ eq.exam_id
|
|
|
+ FROM
|
|
|
+ exam_question eq
|
|
|
+ WHERE
|
|
|
+ eq.exam_id IN ( SELECT DISTINCT exam_id FROM user_exam_record WHERE user_id = #{userId})
|
|
|
+ GROUP BY
|
|
|
+ eq.exam_id ) uer
|
|
|
+ LEFT JOIN exam e ON e.exam_id = uer.exam_id
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getMockRecordRightList" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordQuestionVoResult">
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM
|
|
|
+ question
|
|
|
+ WHERE
|
|
|
+ FIND_IN_SET(
|
|
|
+ question_id,(
|
|
|
+ SELECT
|
|
|
+ right_question_ids
|
|
|
+ FROM
|
|
|
+ user_exam_record uer
|
|
|
+ WHERE
|
|
|
+ uer.user_id = #{userId}
|
|
|
+ AND uer.exam_id = #{examId}
|
|
|
+ ORDER BY
|
|
|
+ record_id DESC
|
|
|
+ LIMIT 1 ))
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getMockRecordWrongList" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultMap="UserMockRecordQuestionVoResult">
|
|
|
+ SELECT
|
|
|
+ q.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ question_id
|
|
|
+ FROM
|
|
|
+ user_exam_wrong_record
|
|
|
+ WHERE
|
|
|
+ record_id = ( SELECT record_id FROM user_exam_record uer WHERE uer.user_id = #{userId} AND uer.exam_id = #{examId} ORDER BY record_id DESC LIMIT 1 )) uewr
|
|
|
+ LEFT JOIN question q ON q.question_id = uewr.question_id
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getUserDoQuestionNum" parameterType="com.zhongzheng.modules.user.bo.UserMockRecordQueryBo" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ IFNULL(count(*),0)
|
|
|
+ FROM
|
|
|
+ question q
|
|
|
+ WHERE
|
|
|
+ FIND_IN_SET(
|
|
|
+ q.question_id,(
|
|
|
+ SELECT
|
|
|
+ GROUP_CONCAT( uer.do_question_ids )
|
|
|
+ FROM
|
|
|
+ user_exam_record uer
|
|
|
+ WHERE
|
|
|
+ uer.user_id = #{userId}
|
|
|
+ AND uer.do_question_ids IS NOT NULL
|
|
|
+ ))
|
|
|
+ </select>
|
|
|
+</mapper>
|