<?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="totalCount" column="total_count" />
|
<result property="exerciseCount" column="exercise_count" />
|
</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
|
</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 del_flag=0
|
<if test="name != null and name != ''">
|
AND name like concat('%', #{name}, '%')
|
</if>
|
<if test="categoryId != null ">
|
AND categoryId =#{categoryId}
|
</if>
|
<if test="status != null ">
|
AND 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},'%')
|
</if>
|
</where>
|
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_exercise_answer where bank_id=#{bankId} and student_id=#{studentId}) as exercise_count
|
from ex_question_bank a
|
where a.bank_id=#{bankId}
|
</select>
|
</mapper>
|