383 lines
12 KiB
XML
383 lines
12 KiB
XML
|
<?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="ink.wgink.module.examine.dao.question.IQuestionDao">
|
||
|
|
||
|
<resultMap id="questionDTO" type="ink.wgink.module.examine.pojo.dtos.question.QuestionDTO">
|
||
|
<id column="question_id" property="questionId"/>
|
||
|
<result column="subject" property="subject"/>
|
||
|
<result column="question_type" property="questionType"/>
|
||
|
<result column="custom_question_type" property="customQuestionType"/>
|
||
|
<result column="type" property="type"/>
|
||
|
<result column="choice_type" property="choiceType"/>
|
||
|
<result column="analysis" property="analysis"/>
|
||
|
<result column="parent_id" property="parentId"/>
|
||
|
<result column="difficulty" property="difficulty"/>
|
||
|
<result column="source" property="source"/>
|
||
|
<result column="answer" property="answer"/>
|
||
|
<result column="gmt_create" property="gmtCreate"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<resultMap id="questionPO" type="ink.wgink.module.examine.pojo.pos.question.QuestionPO">
|
||
|
<id column="question_id" property="questionId"/>
|
||
|
<result column="subject" property="subject"/>
|
||
|
<result column="question_type" property="questionType"/>
|
||
|
<result column="custom_question_type" property="customQuestionType"/>
|
||
|
<result column="type" property="type"/>
|
||
|
<result column="choice_type" property="choiceType"/>
|
||
|
<result column="analysis" property="analysis"/>
|
||
|
<result column="parent_id" property="parentId"/>
|
||
|
<result column="difficulty" property="difficulty"/>
|
||
|
<result column="source" property="source"/>
|
||
|
<result column="answer" property="answer"/>
|
||
|
<result column="gmt_create" property="gmtCreate"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<!-- 建表 -->
|
||
|
<update id="createTable">
|
||
|
|
||
|
</update>
|
||
|
|
||
|
<!-- 新增试题管理 -->
|
||
|
<insert id="save" parameterType="map">
|
||
|
INSERT INTO exam_question(
|
||
|
question_id,
|
||
|
subject,
|
||
|
question_type,
|
||
|
custom_question_type,
|
||
|
type,
|
||
|
choice_type,
|
||
|
analysis,
|
||
|
parent_id,
|
||
|
difficulty,
|
||
|
source,
|
||
|
answer,
|
||
|
creator,
|
||
|
gmt_create,
|
||
|
modifier,
|
||
|
gmt_modified,
|
||
|
is_delete
|
||
|
) VALUES(
|
||
|
#{questionId},
|
||
|
#{subject},
|
||
|
#{questionType},
|
||
|
#{customQuestionType},
|
||
|
#{type},
|
||
|
#{choiceType},
|
||
|
#{analysis},
|
||
|
#{parentId},
|
||
|
#{difficulty},
|
||
|
#{source},
|
||
|
#{answer},
|
||
|
#{creator},
|
||
|
#{gmtCreate},
|
||
|
#{modifier},
|
||
|
#{gmtModified},
|
||
|
#{isDelete}
|
||
|
)
|
||
|
</insert>
|
||
|
|
||
|
<!-- 删除试题管理 -->
|
||
|
<update id="remove" parameterType="map">
|
||
|
UPDATE
|
||
|
exam_question
|
||
|
SET
|
||
|
is_delete = 1,
|
||
|
modifier = #{modifier},
|
||
|
gmt_modified = #{gmtModified}
|
||
|
WHERE
|
||
|
question_id IN
|
||
|
<foreach collection="questionIds" index="index" open="(" separator="," close=")">
|
||
|
#{questionIds[${index}]}
|
||
|
</foreach>
|
||
|
</update>
|
||
|
|
||
|
<!-- 删除试题管理(物理) -->
|
||
|
<update id="delete" parameterType="map">
|
||
|
DELETE FROM
|
||
|
exam_question
|
||
|
WHERE
|
||
|
question_id IN
|
||
|
<foreach collection="questionIds" index="index" open="(" separator="," close=")">
|
||
|
#{questionIds[${index}]}
|
||
|
</foreach>
|
||
|
</update>
|
||
|
|
||
|
<!-- 修改试题管理 -->
|
||
|
<update id="update" parameterType="map">
|
||
|
UPDATE
|
||
|
exam_question
|
||
|
SET
|
||
|
<if test="subject != null and subject != ''">
|
||
|
subject = #{subject},
|
||
|
</if>
|
||
|
<if test="questionType != null">
|
||
|
question_type = #{questionType},
|
||
|
</if>
|
||
|
<if test="customQuestionType != null">
|
||
|
custom_question_type = #{customQuestionType},
|
||
|
</if>
|
||
|
<if test="type != null and type != ''">
|
||
|
type = #{type},
|
||
|
</if>
|
||
|
<if test="choiceType != null and choiceType != ''">
|
||
|
choice_type = #{choiceType},
|
||
|
</if>
|
||
|
<if test="analysis != null and analysis != ''">
|
||
|
analysis = #{analysis},
|
||
|
</if>
|
||
|
<if test="parentId != null and parentId != ''">
|
||
|
parent_id = #{parentId},
|
||
|
</if>
|
||
|
<if test="difficulty != null">
|
||
|
difficulty = #{difficulty},
|
||
|
</if>
|
||
|
<if test="source != null and source != ''">
|
||
|
source = #{source},
|
||
|
</if>
|
||
|
<if test="answer != null and answer != ''">
|
||
|
answer = #{answer},
|
||
|
</if>
|
||
|
modifier = #{modifier},
|
||
|
gmt_modified = #{gmtModified}
|
||
|
WHERE
|
||
|
question_id = #{questionId}
|
||
|
</update>
|
||
|
|
||
|
<!-- 试题管理详情 -->
|
||
|
<select id="get" parameterType="map" resultMap="questionDTO">
|
||
|
SELECT
|
||
|
t1.subject,
|
||
|
t1.question_type,
|
||
|
t1.custom_question_type,
|
||
|
t1.type,
|
||
|
t1.choice_type,
|
||
|
t1.analysis,
|
||
|
t1.parent_id,
|
||
|
t1.difficulty,
|
||
|
t1.source,
|
||
|
t1.answer,
|
||
|
t1.question_id
|
||
|
FROM
|
||
|
exam_question t1
|
||
|
WHERE
|
||
|
t1.is_delete = 0
|
||
|
<if test="questionId != null and questionId != ''">
|
||
|
AND
|
||
|
t1.question_id = #{questionId}
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<!-- 试题管理详情 -->
|
||
|
<select id="getPO" parameterType="map" resultMap="questionPO">
|
||
|
SELECT
|
||
|
t1.subject,
|
||
|
t1.question_type,
|
||
|
t1.custom_question_type,
|
||
|
t1.type,
|
||
|
t1.choice_type,
|
||
|
t1.analysis,
|
||
|
t1.parent_id,
|
||
|
t1.difficulty,
|
||
|
t1.source,
|
||
|
t1.answer,
|
||
|
t1.question_id
|
||
|
FROM
|
||
|
exam_question t1
|
||
|
WHERE
|
||
|
t1.is_delete = 0
|
||
|
<if test="questionId != null and questionId != ''">
|
||
|
AND
|
||
|
t1.question_id = #{questionId}
|
||
|
</if>
|
||
|
<if test="subject != null and subject != ''">
|
||
|
AND
|
||
|
t1.subject = #{subject}
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<!-- 试题管理列表 -->
|
||
|
<select id="list" parameterType="map" resultMap="questionDTO">
|
||
|
SELECT
|
||
|
t1.subject,
|
||
|
t1.question_type,
|
||
|
t1.custom_question_type,
|
||
|
t1.type,
|
||
|
t1.choice_type,
|
||
|
t1.parent_id,
|
||
|
t1.difficulty,
|
||
|
t1.source,
|
||
|
LEFT(t1.gmt_create, 19) gmt_create,
|
||
|
t1.question_id
|
||
|
FROM
|
||
|
exam_question t1
|
||
|
WHERE
|
||
|
t1.is_delete = 0
|
||
|
<if test="keywords != null and keywords != ''">
|
||
|
AND (
|
||
|
t1.subject LIKE CONCAT('%', #{keywords}, '%')
|
||
|
)
|
||
|
</if>
|
||
|
<if test="startTime != null and startTime != ''">
|
||
|
AND
|
||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||
|
</if>
|
||
|
<if test="endTime != null and endTime != ''">
|
||
|
AND
|
||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||
|
</if>
|
||
|
<if test="type != null and type != ''">
|
||
|
AND
|
||
|
t1.type = #{type}
|
||
|
</if>
|
||
|
<if test="choiceType != null and choiceType != ''">
|
||
|
AND
|
||
|
t1.choice_type = #{choiceType}
|
||
|
</if>
|
||
|
<if test="withoutQuestionIds != null and withoutQuestionIds.size > 0">
|
||
|
AND
|
||
|
t1.question_id NOT IN
|
||
|
<foreach collection="withoutQuestionIds" index="index" open="(" separator="," close=")">
|
||
|
#{withoutQuestionIds[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="questionIds != null and questionIds.size > 0">
|
||
|
AND
|
||
|
t1.question_id IN
|
||
|
<foreach collection="questionIds" index="index" open="(" separator="," close=")">
|
||
|
#{questionIds[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="creator != null and creator != ''">
|
||
|
AND
|
||
|
t1.creator = #{creator}
|
||
|
</if>
|
||
|
<if test="creators != null and creators.size > 0">
|
||
|
AND
|
||
|
t1.creator IN
|
||
|
<foreach collection="creators" index="index" open="(" separator="," close=")">
|
||
|
#{creators[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="difficulty != null">
|
||
|
AND
|
||
|
t1.difficulty = #{difficulty}
|
||
|
</if>
|
||
|
<if test="questionType != null and questionType != ''">
|
||
|
AND
|
||
|
t1.question_type = #{questionType}
|
||
|
</if>
|
||
|
<if test="customQuestionTypes != null and customQuestionTypes.size > 0">
|
||
|
AND
|
||
|
<foreach collection="customQuestionTypes" index="index" open="(" separator="OR" close=")">
|
||
|
t1.custom_question_type LIKE CONCAT('%', #{customQuestionTypes[${index}]}, '%')
|
||
|
</foreach>
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<!-- 试题管理统计 -->
|
||
|
<select id="count" parameterType="map" resultType="Integer">
|
||
|
SELECT
|
||
|
COUNT(*)
|
||
|
FROM
|
||
|
exam_question t1
|
||
|
WHERE
|
||
|
t1.is_delete = 0
|
||
|
<if test="creator != null and creator != ''">
|
||
|
AND
|
||
|
t1.creator = #{creator}
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<!-- 试题ID列表 -->
|
||
|
<select id="listIds" parameterType="map" resultType="java.lang.String">
|
||
|
SELECT
|
||
|
question_id
|
||
|
FROM
|
||
|
exam_question
|
||
|
WHERE
|
||
|
is_delete = 0
|
||
|
<if test="type != null and type != ''">
|
||
|
AND
|
||
|
type = #{type}
|
||
|
</if>
|
||
|
<if test="choiceType != null and choiceType != ''">
|
||
|
AND
|
||
|
choice_type = #{choiceType}
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
<!-- 试题列表 -->
|
||
|
<select id="listPO" parameterType="map" resultMap="questionPO">
|
||
|
SELECT
|
||
|
t1.subject,
|
||
|
t1.question_type,
|
||
|
t1.custom_question_type,
|
||
|
t1.type,
|
||
|
t1.choice_type,
|
||
|
t1.parent_id,
|
||
|
t1.difficulty,
|
||
|
t1.source,
|
||
|
LEFT(t1.gmt_create, 19) gmt_create,
|
||
|
t1.question_id
|
||
|
FROM
|
||
|
exam_question t1
|
||
|
WHERE
|
||
|
t1.is_delete = 0
|
||
|
<if test="startTime != null and startTime != ''">
|
||
|
AND
|
||
|
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
|
||
|
</if>
|
||
|
<if test="endTime != null and endTime != ''">
|
||
|
AND
|
||
|
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
|
||
|
</if>
|
||
|
<if test="type != null and type != ''">
|
||
|
AND
|
||
|
t1.type = #{type}
|
||
|
</if>
|
||
|
<if test="choiceType != null and choiceType != ''">
|
||
|
AND
|
||
|
t1.choice_type = #{choiceType}
|
||
|
</if>
|
||
|
<if test="withoutQuestionIds != null and withoutQuestionIds.size > 0">
|
||
|
AND
|
||
|
t1.question_id NOT IN
|
||
|
<foreach collection="withoutQuestionIds" index="index" open="(" separator="," close=")">
|
||
|
#{withoutQuestionIds[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="questionIds != null and questionIds.size > 0">
|
||
|
AND
|
||
|
t1.question_id IN
|
||
|
<foreach collection="questionIds" index="index" open="(" separator="," close=")">
|
||
|
#{questionIds[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="creator != null and creator != ''">
|
||
|
AND
|
||
|
t1.creator = #{creator}
|
||
|
</if>
|
||
|
<if test="creators != null and creators.size > 0">
|
||
|
AND
|
||
|
t1.creator IN
|
||
|
<foreach collection="creators" index="index" open="(" separator="," close=")">
|
||
|
#{creators[${index}]}
|
||
|
</foreach>
|
||
|
</if>
|
||
|
<if test="difficulty != null">
|
||
|
AND
|
||
|
t1.difficulty = #{difficulty}
|
||
|
</if>
|
||
|
<if test="questionType != null and questionType != ''">
|
||
|
AND
|
||
|
t1.question_type = #{questionType}
|
||
|
</if>
|
||
|
<if test="customQuestionTypes != null and customQuestionTypes.size > 0">
|
||
|
AND
|
||
|
<foreach collection="customQuestionTypes" index="index" open="(" separator="OR" close=")">
|
||
|
t1.custom_question_type LIKE CONCAT('%', #{customQuestionTypes[${index}]}, '%')
|
||
|
</foreach>
|
||
|
</if>
|
||
|
</select>
|
||
|
|
||
|
</mapper>
|