From f0f00e9ba8a755e4317e029d73b69a92ad9f9df1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: Sat, 14 Sep 2024 17:02:41 +0800
Subject: [PATCH] update
---
exam-system/src/main/resources/mapper/system/ExQuestionBankMapper.xml | 69 ++++++++++++++++++++++------------
1 files changed, 45 insertions(+), 24 deletions(-)
diff --git a/exam-system/src/main/resources/mapper/system/ExQuestionBankMapper.xml b/exam-system/src/main/resources/mapper/system/ExQuestionBankMapper.xml
index bac3350..87ff02d 100644
--- a/exam-system/src/main/resources/mapper/system/ExQuestionBankMapper.xml
+++ b/exam-system/src/main/resources/mapper/system/ExQuestionBankMapper.xml
@@ -15,14 +15,23 @@
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
+ <result property="singleCount" column="single_count" />
+ <result property="multiCount" column="multi_count" />
+ <result property="judgeCount" column="judge_count" />
<result property="totalCount" column="total_count" />
<result property="exerciseCount" column="exercise_count" />
+ <result property="categoryName" column="category_name" />
+ <result property="questionId" column="question_id" />
</resultMap>
<sql id="selectQuestionBankVo">
- select id, name, category_id, status, del_flag,company_id,privatize,version, create_by, create_time, update_by, update_time, remark,
- (select count(1) from ex_question where bank_id=a.id) as total_count
- from ex_question_bank
+ select a.id, a.name, a.category_id, a.status, a.del_flag,a.company_id,a.privatize,a.version,
+ a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as category_name,
+ (select count(1) from ex_question where bank_id=a.id and question_type=1) as single_count,
+ (select count(1) from ex_question where bank_id=a.id and question_type=2) as multi_count,
+ (select count(1) from ex_question where bank_id=a.id and question_type=3) as judge_count
+ from ex_question_bank a
+ left join sys_category b on b.id=a.category_id
</sql>
<update id="deleteByBankId">
@@ -40,43 +49,55 @@
<select id="selectQuestionBankList" resultMap="ExQuestionBankResult">
<include refid="selectQuestionBankVo"/>
<where>
- and del_flag=0
+ and a.del_flag=0
<if test="name != null and name != ''">
- AND name like concat('%', #{name}, '%')
+ AND a.name like concat('%', #{name}, '%')
</if>
<if test="categoryId != null ">
- AND categoryId =#{categoryId}
+ AND a.category_id =#{categoryId}
</if>
<if test="status != null ">
- AND status =#{status}
+ AND a.status =#{status}
</if>
<if test="companyId != null ">
- AND (company_id =#{companyId} or privatize=1)
- </if>
- </where>
- order by id desc
- </select>
-
- <select id="selectQuestionBankListForStudent" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
- select a.*,
- (select count(1) from ex_question where bank_id=a.id) as total_count,
- b.exe_count as exercise_count
- from ex_question_bank a
- left join (select bank_id,count(*) as exe_count from ex_exercise_answer where student_id=#{studentId} group by bank_id) b on b.bank_id=a.id
- <where>
- and (a.company_id=#{companyId} or a.privatize=1) and a.del_flag=0
- <if test="name!=null and name!=''">
- a.name like concat('%',#{name},'%')
+ AND (a.company_id =#{companyId} or a.privatize=1)
</if>
</where>
order by a.id desc
</select>
+ <select id="selectQuestionBankListForStudent" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
+ select a.*,
+ (select count(1) from ex_question where bank_id=a.id ) as total_count,
+ (select count(1) from ex_exercise_answer where bank_id=a.id and student_id=#{studentId}) as exercise_count,
+ (select question_id from ex_exercise_answer where bank_id=a.id and student_id=#{studentId} order by id desc limit 1) as question_id
+ from ex_question_bank a
+ where a.del_flag=0 and (a.company_id=#{companyId} or a.privatize=1)
+ order by a.id desc
+ </select>
+
<select id="selectQuestionBankByIdForStudent" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
select a.*,
- (select count(1) from ex_question where bank_id=a.id) as total_count,
+ (select count(1) from ex_question where bank_id=a.id and question_type=1) as single_count,
+ (select count(1) from ex_question where bank_id=a.id and question_type=2) as multi_count,
+ (select count(1) from ex_question where bank_id=a.id and question_type=3) as judge_count,
(select count(1) from ex_exercise_answer where bank_id=#{bankId} and student_id=#{studentId}) as exercise_count
from ex_question_bank a
where a.bank_id=#{bankId}
</select>
+
+ <select id="selectCountByBankId" resultType="java.lang.Integer" parameterType="java.lang.Long">
+ select count(1) from ex_question_bank where del_flag=0 and id=#{bankId}
+ </select>
+
+ <select id="selectCountByCategoryId" resultType="java.lang.Integer">
+ select count(1) from ex_question_bank where category_id=#{categoryId} and del_flag=0
+ </select>
+
+ <select id="selectQuestionBankByIds" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
+ select * from ex_question_bank where del_flag=0 and id in
+ <foreach collection="bankIds" item="bankId" index="index" separator="," open="(" close=")">
+ #{bankId}
+ </foreach>
+ </select>
</mapper>
--
Gitblit v1.9.2