<?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.ots.project.exam.mapper.TQuestionMapper">
|
|
<resultMap type="TQuestion" id="TQuestionResult">
|
<result property="id" column="id"/>
|
<result property="questionType" column="question_type"/>
|
<result property="levelId" column="level_id"/>
|
<result property="levelName" column="level_name"/>
|
<result property="subjectId" column="subject_id"/>
|
<result property="langType" column="lang_type"/>
|
<result property="score" column="score"/>
|
<result property="gradeLevel" column="grade_level"/>
|
<result property="difficult" column="difficult"/>
|
<result property="correct" column="correct"/>
|
<result property="infoTextContentId" column="info_text_content_id"/>
|
<result property="createUser" column="create_user"/>
|
<result property="status" column="status"/>
|
<result property="createTime" column="create_time"/>
|
<result property="deleted" column="deleted"/>
|
<result property="subjectName" column="subject_name"/>
|
<result property="permanentId" column="permanent_id"/>
|
<result property="questionTemplateId" column="question_template_id"/>
|
<result property="template" column="template"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id, question_type, subject_id,lang_type, score, grade_level, difficult, correct, info_text_content_id,
|
create_user, status, create_time, deleted, permanent_id, template
|
</sql>
|
|
<sql id="selectTQuestionVo">
|
select id, question_type,lang_type, subject_id, score, grade_level, difficult, correct, info_text_content_id, create_user, status, create_time, deleted, template from t_question
|
</sql>
|
|
<sql id="selectTQuestioAndTTextContent">
|
select tq.id, tq.question_type, tq.lang_type,tq.subject_id, tq.score, tq.grade_level, tq.difficult, tq.correct, tq.info_text_content_id, tq.create_user, tq.status, tq.create_time, tq.deleted, tt.content content, tel.level_name level_name, tel.id level_id, tq.permanent_id permanent_id, tel.question_template_id question_template_id, tq.template from t_question tq,t_text_content tt, t_exam_level tel
|
</sql>
|
|
<select id="selectTQuestionList" parameterType="TQuestion" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
<where>
|
tq.info_text_content_id = tt.id and tq.level_id = tel.id and tq.deleted in(0,1)
|
<if test="levelName != null ">and tel.level_name like concat('%', #{levelName}, '%')</if>
|
<if test="title != null and title !=''">and tt.content like concat('%', #{title}, '%')</if>
|
<if test="levelId != null ">and tel.id = #{levelId}</if>
|
<if test="uuid != null and uuid !=''">and tq.id = #{uuid}</if>
|
<if test="questionTemplateId != null and questionTemplateId !=''">and tel.question_template_id = #{questionTemplateId}</if>
|
<if test="template != null and template !=''">and tq.template = #{template}</if>
|
</where>
|
order by tq.create_time desc
|
</select>
|
|
<select id="selectTQuestionsForProductAddQuestion" parameterType="TQuestion" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
<where>
|
tq.info_text_content_id = tt.id and tq.level_id = tel.id and tq.deleted in(0,1)
|
<if test="levelName != null ">and tel.level_name like concat('%', #{levelName}, '%')</if>
|
<if test="title != null and title !=''">and tt.content like concat('%', #{title}, '%')</if>
|
<if test="levelId != null ">and tel.id = #{levelId}</if>
|
<if test="questionTemplateId != null and questionTemplateId !=''">and (tel.question_template_id = #{questionTemplateId} or tq.template = #{questionTemplateId} )</if>
|
<if test="questionTemplateId == null or questionTemplateId ==''">and ifnull(tq.template, "") != 'job_title' </if>
|
<if test="template != null and template !=''">and tq.template = #{template}</if>
|
</where>
|
order by tq.create_time asc
|
</select>
|
|
<select id="selectTQuestionById" parameterType="Long" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
where tq.id = #{id} and tq.info_text_content_id = tt.id and tel.id = tq.level_id
|
order by tq.create_time desc
|
</select>
|
|
<select id="selectTQuestionByPermanentId" parameterType="String" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
where tq.permanent_id = #{permanentId} and tq.info_text_content_id = tt.id and tel.id = tq.level_id and tq.deleted in(0, 1)
|
order by tq.create_time asc
|
</select>
|
|
<select id="selectTQuestionByIds" parameterType="Long" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
where tq.info_text_content_id = tt.id and tel.id = tq.level_id and tq.id in
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
order by tq.create_time desc
|
</select>
|
|
<select id="selectTQuestionScore" parameterType="Integer" resultMap="TQuestionResult">
|
SELECT sum(q.score) score from t_question q,t_text_content ttc
|
where q.info_text_content_id = ttc.id and q.id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<insert id="insertTQuestion" parameterType="TQuestion" useGeneratedKeys="true" keyProperty="id">
|
insert into t_question
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="questionType != null ">question_type,</if>
|
<if test="levelId != null ">level_id,</if>
|
<if test="subjectId != null ">subject_id,</if>
|
<if test="score != null ">score,</if>
|
<if test="langType != null ">lang_type,</if>
|
<if test="gradeLevel != null ">grade_level,</if>
|
<if test="difficult != null ">difficult,</if>
|
<if test="correct != null and correct != ''">correct,</if>
|
<if test="infoTextContentId != null ">info_text_content_id,</if>
|
<if test="createUser != null ">create_user,</if>
|
<if test="status != null ">status,</if>
|
<if test="createTime != null ">create_time,</if>
|
<if test="deleted != null ">deleted,</if>
|
<if test="permanentId != null ">permanent_id,</if>
|
<if test="lastId != null ">last_id,</if>
|
<if test="template != null ">template,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="questionType != null ">#{questionType},</if>
|
<if test="levelId != null ">#{levelId},</if>
|
<if test="subjectId != null ">#{subjectId},</if>
|
<if test="score != null ">#{score},</if>
|
<if test="langType != null ">#{langType},</if>
|
<if test="gradeLevel != null ">#{gradeLevel},</if>
|
<if test="difficult != null ">#{difficult},</if>
|
<if test="correct != null and correct != ''">#{correct},</if>
|
<if test="infoTextContentId != null ">#{infoTextContentId},</if>
|
<if test="createUser != null ">#{createUser},</if>
|
<if test="status != null ">#{status},</if>
|
<if test="createTime != null ">#{createTime},</if>
|
<if test="deleted != null ">#{deleted},</if>
|
<if test="permanentId != null ">#{permanentId},</if>
|
<if test="lastId != null ">#{lastId},</if>
|
<if test="template != null ">#{template},</if>
|
</trim>
|
</insert>
|
|
<update id="updateTQuestion" parameterType="TQuestion">
|
update t_question
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="questionType != null ">question_type = #{questionType},</if>
|
<if test="subjectId != null ">subject_id = #{subjectId},</if>
|
<if test="score != null ">score = #{score},</if>
|
<if test="langType != null ">lang_type = #{langType},</if>
|
<if test="gradeLevel != null ">grade_level = #{gradeLevel},</if>
|
<if test="difficult != null ">difficult = #{difficult},</if>
|
<if test="correct != null and correct != ''">correct = #{correct},</if>
|
<if test="infoTextContentId != null ">info_text_content_id = #{infoTextContentId},</if>
|
<if test="createUser != null ">create_user = #{createUser},</if>
|
<if test="status != null ">status = #{status},</if>
|
<if test="createTime != null ">create_time = #{createTime},</if>
|
<if test="deleted != null ">deleted = #{deleted},</if>
|
<if test="permanentId != null ">permanent_id = #{permanentId},</if>
|
<if test="template != null ">template = #{template},</if>
|
</trim>
|
<where>
|
id = #{id}
|
</where>
|
</update>
|
|
|
<update id="updateTQuestionByPermanentId" parameterType="TQuestion">
|
update t_question
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="questionType != null ">question_type = #{questionType},</if>
|
<if test="subjectId != null ">subject_id = #{subjectId},</if>
|
<if test="score != null ">score = #{score},</if>
|
<if test="langType != null ">lang_type = #{langType},</if>
|
<if test="gradeLevel != null ">grade_level = #{gradeLevel},</if>
|
<if test="difficult != null ">difficult = #{difficult},</if>
|
<if test="correct != null and correct != ''">correct = #{correct},</if>
|
<if test="infoTextContentId != null ">info_text_content_id = #{infoTextContentId},</if>
|
<if test="createUser != null ">create_user = #{createUser},</if>
|
<if test="status != null ">status = #{status},</if>
|
<if test="createTime != null ">create_time = #{createTime},</if>
|
<if test="deleted != null ">deleted = #{deleted},</if>
|
<if test="permanentId != null ">permanent_id = #{permanentId},</if>
|
</trim>
|
<where>
|
permanent_id = #{permanentId}
|
<if test="langType != null ">and lang_type = #{langType}</if>
|
</where>
|
</update>
|
|
<delete id="deleteTQuestionById" parameterType="Long">
|
delete from t_question where id = #{id}
|
</delete>
|
|
<delete id="deleteTQuestionByIds" parameterType="String">
|
delete from t_question where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<delete id="updateQuetionByDelete" parameterType="String">
|
update t_question set deleted = 2 where id in
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="selectByIds" resultMap="TQuestionResult">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM t_question where id in
|
<foreach item="id" collection="ids" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
</select>
|
|
<select id="selectTQuestionByPermanentIds" parameterType="Long" resultMap="TQuestionResult">
|
<include refid="selectTQuestioAndTTextContent"/>
|
where tq.deleted = 1 and tq.info_text_content_id = tt.id and tel.id = tq.level_id and tq.permanent_id in
|
<foreach item="permanentId" collection="list" open="(" separator="," close=")">
|
#{permanentId}
|
</foreach>
|
order by tq.create_time desc
|
</select>
|
|
</mapper>
|