<?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.ruoyi.abuwx.mapper.exam.ExmQuestionAnswerMapper">
    
    <resultMap type="ExmQuestionAnswer" id="ExmQuestionAnswerResult">
        <result property="id"    column="ID"    />
        <result property="answer"    column="ANSWER"    />
        <result property="score"    column="SCORE"    />
        <result property="questionId"    column="QUESTION_ID"    />
        <result property="no"    column="NO"    />
    </resultMap>

    <sql id="selectExmQuestionAnswerVo">
        select ID, ANSWER, SCORE, QUESTION_ID, NO from exm_question_answer
    </sql>

    <select id="selectExmQuestionAnswerList" parameterType="ExmQuestionAnswer" resultMap="ExmQuestionAnswerResult">
        <include refid="selectExmQuestionAnswerVo"/>
        <where>  
            <if test="answer != null  and answer != ''"> and ANSWER = #{answer}</if>
            <if test="score != null "> and SCORE = #{score}</if>
            <if test="questionId != null "> and QUESTION_ID = #{questionId}</if>
            <if test="no != null "> and NO = #{no}</if>
        </where>
    </select>
    
    <select id="selectExmQuestionAnswerById" parameterType="Long" resultMap="ExmQuestionAnswerResult">
        <include refid="selectExmQuestionAnswerVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertExmQuestionAnswer" parameterType="ExmQuestionAnswer" useGeneratedKeys="true" keyProperty="id">
        insert into exm_question_answer
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="answer != null">ANSWER,</if>
            <if test="score != null">SCORE,</if>
            <if test="questionId != null">QUESTION_ID,</if>
            <if test="no != null">NO,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="answer != null">#{answer},</if>
            <if test="score != null">#{score},</if>
            <if test="questionId != null">#{questionId},</if>
            <if test="no != null">#{no},</if>
         </trim>
    </insert>

    <update id="updateExmQuestionAnswer" parameterType="ExmQuestionAnswer">
        update exm_question_answer
        <trim prefix="SET" suffixOverrides=",">
            <if test="answer != null">ANSWER = #{answer},</if>
            <if test="score != null">SCORE = #{score},</if>
            <if test="questionId != null">QUESTION_ID = #{questionId},</if>
            <if test="no != null">NO = #{no},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteExmQuestionAnswerById" parameterType="Long">
        delete from exm_question_answer where ID = #{id}
    </delete>

    <delete id="deleteExmQuestionAnswerByIds" parameterType="String">
        delete from exm_question_answer where ID in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>