From f33f56fb2ebfea915b93467698ca6b243ee934ba Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期二, 16 七月 2024 17:32:49 +0800 Subject: [PATCH] 导出完善 --- src/main/resources/mapper/QuestionSubjectMapper.xml | 66 +++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/main/resources/mapper/QuestionSubjectMapper.xml b/src/main/resources/mapper/QuestionSubjectMapper.xml index 1b05d52..e9912cf 100644 --- a/src/main/resources/mapper/QuestionSubjectMapper.xml +++ b/src/main/resources/mapper/QuestionSubjectMapper.xml @@ -57,11 +57,13 @@ <select id="countQuestionNum" resultType="integer"> SELECT - count(distinct id) + count(distinct tqs.question_id) FROM - t_question_subject + t_question_subject tqs + INNER JOIN t_question tq ON tq.id = tqs.question_id <if test="questionType != -99">AND tq.question_type = #{questionType}</if> WHERE - subject_id IN <foreach collection="subjects" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach> + tqs.subject_id IN <foreach collection="subjects" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach> + </select> <select id="getRandomQuestionId" resultType="com.mindskip.xzs.domain.vo.QuestionVO"> @@ -70,10 +72,15 @@ tq.id, tq.question_type as questionType, tq.difficult, - ttc.content as contentJson + ttc.content as contentJson, + tq.correct FROM t_question_subject tqs - INNER JOIN t_question tq ON tqs.question_id = tq.id AND tq.deleted = 0 AND tqs.subject_id IN <foreach collection="subjectIds" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach> + INNER JOIN t_question tq ON tqs.question_id = tq.id AND tq.deleted = 0 + <if test="questionType != null and questionType != -99"> + AND tq.question_type = #{questionType} + </if> + AND tqs.subject_id IN <foreach collection="subjectIds" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach> INNER JOIN t_text_content ttc ON tq.info_text_content_id = ttc.id ORDER BY RAND() LIMIT #{questionNum} @@ -91,24 +98,67 @@ id DESC </select> - <select id="questionsBySubjectId" resultType="integer"> + <select id="questionsBySubjectId" resultType="integer"> SELECT - tqs.question_id + tqs.question_id, ttc.content FROM t_question_subject tqs INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId} + INNER JOIN t_text_content ttc ON ttc.id = tq.info_text_content_id ORDER BY tqs.id DESC </select> <select id="questionsBySubjectIdAndQuestionType" resultType="integer"> SELECT - tqs.question_id + tqs.question_id, ttc.content FROM t_question_subject tqs INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId} AND tq.question_type = #{questionType} + INNER JOIN t_text_content ttc ON ttc.id = tq.info_text_content_id ORDER BY tqs.id DESC </select> + <select id="bySubjectId" resultType="com.mindskip.xzs.domain.vo.QuestionVO"> + SELECT + tq.id, + tq.question_type, + tq.correct, + ttc.content as contentJson + FROM + t_question_subject tqs + INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId} + INNER JOIN t_text_content ttc ON ttc.id = tq.info_text_content_id + ORDER BY + tq.id DESC + </select> + + <select id="bySubjectIdAndQuestionType" resultType="com.mindskip.xzs.domain.vo.QuestionVO"> + SELECT + tq.id, + tq.question_type, + tq.correct, + ttc.content as contentJson + FROM + t_question_subject tqs + INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId} AND tq.question_type = #{questionType} + INNER JOIN t_text_content ttc ON ttc.id = tq.info_text_content_id + ORDER BY + tq.id DESC + </select> + + <select id="getSubjectBySubjectIds" resultType="com.mindskip.xzs.domain.QuestionSubject"> + select qs.*,s.name as subName + from t_question_subject qs + left join t_subject s on qs.subject_id = s.id + where qs.deleted = 0 and s.deleted = 0 + <if test="subjectIds != null and subjectIds.length > 0"> + and qs.subject_id in + <foreach collection="subjectIds" item="subjectId" open="(" separator="," close=")"> + #{subjectId} + </foreach> + </if> + </select> + </mapper> -- Gitblit v1.8.0