167 lines
5.1 KiB
XML
167 lines
5.1 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.IQuestionOptionsDao">
|
||
|
||
<resultMap id="questionOptionsDTO" type="ink.wgink.module.examine.pojo.dtos.question.QuestionOptionsDTO">
|
||
<id column="question_options_id" property="questionOptionsId"/>
|
||
<result column="question_id" property="questionId"/>
|
||
<result column="question_option" property="option"/>
|
||
<result column="content" property="content"/>
|
||
</resultMap>
|
||
|
||
<!-- 建表 -->
|
||
<update id="createTable">
|
||
|
||
</update>
|
||
|
||
<!-- 新增试题选项 -->
|
||
<insert id="save" parameterType="map">
|
||
INSERT INTO exam_question_options(
|
||
question_options_id,
|
||
question_id,
|
||
question_option,
|
||
content,
|
||
creator,
|
||
gmt_create,
|
||
modifier,
|
||
gmt_modified,
|
||
is_delete
|
||
) VALUES(
|
||
#{questionOptionsId},
|
||
#{questionId},
|
||
#{option},
|
||
#{content},
|
||
#{creator},
|
||
#{gmtCreate},
|
||
#{modifier},
|
||
#{gmtModified},
|
||
#{isDelete}
|
||
)
|
||
</insert>
|
||
|
||
<!-- 删除试题选项 -->
|
||
<update id="remove" parameterType="map">
|
||
UPDATE
|
||
exam_question_options
|
||
SET
|
||
is_delete = 1,
|
||
modifier = #{modifier},
|
||
gmt_modified = #{gmtModified}
|
||
WHERE
|
||
question_options_id IN
|
||
<foreach collection="questionOptionsIds" index="index" open="(" separator="," close=")">
|
||
#{questionOptionsIds[${index}]}
|
||
</foreach>
|
||
</update>
|
||
|
||
<!-- 删除试题选项(物理) -->
|
||
<delete id="delete" parameterType="map">
|
||
DELETE FROM
|
||
exam_question_options
|
||
WHERE
|
||
question_options_id IN
|
||
<foreach collection="questionOptionsIds" index="index" open="(" separator="," close=")">
|
||
#{questionOptionsIds[${index}]}
|
||
</foreach>
|
||
</delete>
|
||
|
||
<!-- 删除选项(通过试题ID) -->
|
||
<delete id="deleteByQuestionId" parameterType="java.lang.String">
|
||
DELETE FROM
|
||
exam_question_options
|
||
WHERE
|
||
question_id = #{_parameter}
|
||
</delete>
|
||
|
||
<!-- 修改试题选项 -->
|
||
<update id="update" parameterType="map">
|
||
UPDATE
|
||
exam_question_options
|
||
SET
|
||
<if test="questionId != null and questionId != ''">
|
||
question_id = #{questionId},
|
||
</if>
|
||
<if test="option != null and option != ''">
|
||
question_option = #{option},
|
||
</if>
|
||
<if test="content != null and content != ''">
|
||
content = #{content},
|
||
</if>
|
||
modifier = #{modifier},
|
||
gmt_modified = #{gmtModified}
|
||
WHERE
|
||
question_options_id = #{questionOptionsId}
|
||
</update>
|
||
|
||
<!-- 试题选项详情 -->
|
||
<select id="get" parameterType="map" resultMap="questionOptionsDTO">
|
||
SELECT
|
||
t1.question_id,
|
||
t1.question_option,
|
||
t1.content,
|
||
t1.question_options_id
|
||
FROM
|
||
exam_question_options t1
|
||
WHERE
|
||
t1.is_delete = 0
|
||
<if test="questionOptionsId != null and questionOptionsId != ''">
|
||
AND
|
||
t1.question_options_id = #{questionOptionsId}
|
||
</if>
|
||
</select>
|
||
|
||
<!-- 试题选项列表 -->
|
||
<select id="list" parameterType="map" resultMap="questionOptionsDTO">
|
||
SELECT
|
||
t1.question_id,
|
||
t1.question_option,
|
||
t1.content,
|
||
t1.question_options_id
|
||
FROM
|
||
exam_question_options t1
|
||
WHERE
|
||
t1.is_delete = 0
|
||
<if test="keywords != null and keywords != ''">
|
||
AND (
|
||
t1.content LIKE CONCAT('%', #{keywords}, '%')
|
||
)
|
||
</if>
|
||
<if test="questionId != null and questionId != ''">
|
||
AND
|
||
t1.question_id = #{questionId}
|
||
</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="questionOptionsIds != null and questionOptionsIds.size > 0">
|
||
AND
|
||
t1.question_options_id IN
|
||
<foreach collection="questionOptionsIds" index="index" open="(" separator="," close=")">
|
||
#{questionOptionsIds[${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>
|
||
</select>
|
||
|
||
<!-- 试题选项统计 -->
|
||
<select id="count" parameterType="map" resultType="Integer">
|
||
SELECT
|
||
COUNT(*)
|
||
FROM
|
||
exam_question_options t1
|
||
WHERE
|
||
t1.is_delete = 0
|
||
</select>
|
||
|
||
</mapper> |