<?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.gkhy.exam.system.mapper.ExQuestionBankMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExQuestionBank" id="ExQuestionBankResult">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="categoryId" column="category_id" />
|
<result property="status" column="status" />
|
<result property="delFlag" column="del_flag" />
|
<result property="companyId" column="company_id" />
|
<result property="privatize" column="privatize" />
|
<result property="version" column="version" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<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 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">
|
update ex_question_bank set del_flag=1 where id=#{bankId}
|
</update>
|
|
<select id="checkNameUniqueForAdmin" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
|
select id,name from ex_question_bank where name=#{name} and privatize=1 and del_flag=0 limit 1
|
</select>
|
|
<select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExQuestionBank">
|
select id,name from ex_question_bank where name=#{name} and company_id=#{companyId} and del_flag=0 limit 1
|
</select>
|
|
<select id="selectQuestionBankList" resultMap="ExQuestionBankResult">
|
<include refid="selectQuestionBankVo"/>
|
<where>
|
and a.del_flag=0
|
<if test="name != null and name != ''">
|
AND a.name like concat('%', #{name}, '%')
|
</if>
|
<if test="categoryId != null ">
|
AND a.category_id =#{categoryId}
|
</if>
|
<if test="status != null ">
|
AND a.status =#{status}
|
</if>
|
<if test="companyId != null ">
|
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 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>
|