Files
pengchen-exam-java/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionAnswerMapper.xml

119 lines
5.5 KiB
XML
Raw Normal View History

<?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="pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper">
<resultMap type="ExamQuestionAnswer" id="ExamQuestionAnswerResult">
<result property="answerId" column="answer_id" />
<result property="quId" column="qu_id" />
<result property="isRight" column="is_right" />
<result property="image" column="image" />
<result property="content" column="content" />
<result property="contentIn" column="contentIn" />
<result property="scoreRate" column="score_rate" />
<result property="sort" column="sort" />
</resultMap>
<sql id="selectExamQuestionAnswerVo">
select answer_id, qu_id, is_right, image, content,contentIn, score_rate,sort from exam_question_answer
</sql>
<select id="selectExamQuestionAnswerList" parameterType="ExamQuestionAnswer" resultMap="ExamQuestionAnswerResult">
<include refid="selectExamQuestionAnswerVo"/>
<where>
<if test="quId != null and quId != ''"> and qu_id = #{quId}</if>
<if test="isRight != null and isRight != ''"> and is_right = #{isRight}</if>
<if test="image != null and image != ''"> and image = #{image}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
<if test="scoreRate != null and scoreRate != ''"> and score_rate = #{scoreRate}</if>
</where>
</select>
<select id="selectExamQuestionAnswerByAnswerId" parameterType="String" resultMap="ExamQuestionAnswerResult">
<include refid="selectExamQuestionAnswerVo"/>
where answer_id = #{answerId}
</select>
<insert id="insertExamQuestionAnswer" parameterType="ExamQuestionAnswer">
insert into exam_question_answer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="answerId != null">answer_id,</if>
<if test="quId != null">qu_id,</if>
<if test="isRight != null">is_right,</if>
<if test="image != null">image,</if>
<if test="content != null">content,</if>
<if test="contentIn != null">contentIn,</if>
<if test="scoreRate != null">score_rate,</if>
<if test="sort != null">sort,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="answerId != null">#{answerId},</if>
<if test="quId != null">#{quId},</if>
<if test="isRight != null">#{isRight},</if>
<if test="image != null">#{image},</if>
<if test="content != null">#{content},</if>
<if test="contentIn != null">#{contentIn},</if>
<if test="scoreRate != null">#{scoreRate},</if>
<if test="sort != null">#{sort},</if>
</trim>
</insert>
<update id="updateExamQuestionAnswer" parameterType="ExamQuestionAnswer">
update exam_question_answer
<trim prefix="SET" suffixOverrides=",">
<if test="quId != null">qu_id = #{quId},</if>
<if test="isRight != null">is_right = #{isRight},</if>
<if test="image != null">image = #{image},</if>
<if test="content != null">content = #{content},</if>
<if test="contentIn != null">contentIn = #{contentIn},</if>
<if test="scoreRate != null">score_rate = #{scoreRate},</if>
<if test="sort != null">sort = #{sort},</if>
</trim>
where answer_id = #{answerId}
</update>
<delete id="deleteExamQuestionAnswerByAnswerId" parameterType="String">
delete from exam_question_answer where answer_id = #{answerId}
</delete>
<delete id="deleteExamQuestionAnswerByAnswerIds" parameterType="String">
delete from exam_question_answer where answer_id in
<foreach item="answerId" collection="array" open="(" separator="," close=")">
#{answerId}
</foreach>
</delete>
<select id="selectExamQuestionAnswerByQuId" resultMap="ExamQuestionAnswerResult">
<include refid="selectExamQuestionAnswerVo"/>
<where>
<if test="quId != null "> and qu_id = #{quId}</if>
</where>
ORDER BY sort ASC
</select>
<select id="selectExamQuestionAnswerIdByQuId" resultType="java.lang.String">
select answer_id from exam_question_answer where qu_id =#{quId}
</select>
<select id="selectAnswerFile" resultType="java.lang.String">
select url from sys_file where qu_id =#{quId} and file_type ='2'
</select>
<insert id="insertExamQuestionAnswerList">
insert into exam_question_answer
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort)
values
<foreach collection="collection" separator="," item="item">
(#{item.answerId},#{item.quId},#{item.isRight},#{item.image},#{item.content},#{item.contentIn},#{item.scoreRate},#{item.sort})
</foreach>
</insert>
<delete id="deleteExamQuestionAnswerByQuesId">
delete from exam_question_answer where qu_id = #{firstQuId}
</delete>
<delete id="deleteExamQuestionAnswerByQuesIds" parameterType="String">
delete from exam_question_answer where qu_id in
<foreach collection="ids" item="firstQuId" open="(" separator="," close=")">
#{firstQuId}
</foreach>
</delete>
</mapper>