<?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.sy.mapper.SyTestQuestionMapper">
    
    <resultMap type="SyTestQuestion" id="SyTestQuestionResult">
        <result property="questionId"    column="question_id"    />
        <result property="paperId"    column="paper_id"    />
        <result property="seq"    column="seq"    />
        <result property="title"    column="title"    />
        <result property="optionA"    column="option_a"    />
        <result property="optionB"    column="option_b"    />
        <result property="optionC"    column="option_c"    />
        <result property="optionD"    column="option_d"    />
        <result property="optionE"    column="option_e"    />
        <result property="valueA"    column="value_a"    />
        <result property="valueB"    column="value_b"    />
        <result property="valueC"    column="value_c"    />
        <result property="valueD"    column="value_d"    />
        <result property="valueE"    column="value_e"    />
        <result property="quesitonCateogry"    column="quesiton_cateogry"    />
        <result property="answer1"    column="answer1"    />
        <result property="answer2"    column="answer2"    />
        <result property="parse"    column="parse"    />
        <result property="score"    column="score"    />
        <result property="qtpye"    column="qtpye"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSyTestQuestionVo">
        select question_id, paper_id, seq, title, option_a, option_b, option_c, option_d, option_e, value_a, value_b, value_c, value_d, value_e, quesiton_cateogry, answer1, answer2, parse, score, qtpye, create_time from sy_test_question
    </sql>

    <select id="selectSyTestQuestionList" parameterType="SyTestQuestion" resultMap="SyTestQuestionResult">
        <include refid="selectSyTestQuestionVo"/>
        <where>  
            <if test="paperId != null "> and paper_id = #{paperId}</if>
            <if test="seq != null "> and seq = #{seq}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="optionA != null  and optionA != ''"> and option_a = #{optionA}</if>
            <if test="optionB != null  and optionB != ''"> and option_b = #{optionB}</if>
            <if test="optionC != null  and optionC != ''"> and option_c = #{optionC}</if>
            <if test="optionD != null  and optionD != ''"> and option_d = #{optionD}</if>
            <if test="optionE != null  and optionE != ''"> and option_e = #{optionE}</if>
            <if test="valueA != null  and valueA != ''"> and value_a = #{valueA}</if>
            <if test="valueB != null  and valueB != ''"> and value_b = #{valueB}</if>
            <if test="valueC != null  and valueC != ''"> and value_c = #{valueC}</if>
            <if test="valueD != null  and valueD != ''"> and value_d = #{valueD}</if>
            <if test="valueE != null  and valueE != ''"> and value_e = #{valueE}</if>
            <if test="quesitonCateogry != null  and quesitonCateogry != ''"> and quesiton_cateogry = #{quesitonCateogry}</if>
            <if test="answer1 != null  and answer1 != ''"> and answer1 = #{answer1}</if>
            <if test="answer2 != null  and answer2 != ''"> and answer2 = #{answer2}</if>
            <if test="parse != null  and parse != ''"> and parse = #{parse}</if>
            <if test="score != null "> and score = #{score}</if>
            <if test="qtpye != null  and qtpye != ''"> and qtpye = #{qtpye}</if>
        </where>
        order by seq
    </select>
    
    <select id="selectSyTestQuestionById" parameterType="Long" resultMap="SyTestQuestionResult">
        <include refid="selectSyTestQuestionVo"/>
        where question_id = #{questionId}
    </select>
        
    <insert id="insertSyTestQuestion" parameterType="SyTestQuestion" useGeneratedKeys="true" keyProperty="questionId">
        insert into sy_test_question
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="paperId != null">paper_id,</if>
            <if test="seq != null">seq,</if>
            <if test="title != null">title,</if>
            <if test="optionA != null">option_a,</if>
            <if test="optionB != null">option_b,</if>
            <if test="optionC != null">option_c,</if>
            <if test="optionD != null">option_d,</if>
            <if test="optionE != null">option_e,</if>
            <if test="valueA != null">value_a,</if>
            <if test="valueB != null">value_b,</if>
            <if test="valueC != null">value_c,</if>
            <if test="valueD != null">value_d,</if>
            <if test="valueE != null">value_e,</if>
            <if test="quesitonCateogry != null">quesiton_cateogry,</if>
            <if test="answer1 != null">answer1,</if>
            <if test="answer2 != null">answer2,</if>
            <if test="parse != null">parse,</if>
            <if test="score != null">score,</if>
            <if test="qtpye != null">qtpye,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="paperId != null">#{paperId},</if>
            <if test="seq != null">#{seq},</if>
            <if test="title != null">#{title},</if>
            <if test="optionA != null">#{optionA},</if>
            <if test="optionB != null">#{optionB},</if>
            <if test="optionC != null">#{optionC},</if>
            <if test="optionD != null">#{optionD},</if>
            <if test="optionE != null">#{optionE},</if>
            <if test="valueA != null">#{valueA},</if>
            <if test="valueB != null">#{valueB},</if>
            <if test="valueC != null">#{valueC},</if>
            <if test="valueD != null">#{valueD},</if>
            <if test="valueE != null">#{valueE},</if>
            <if test="quesitonCateogry != null">#{quesitonCateogry},</if>
            <if test="answer1 != null">#{answer1},</if>
            <if test="answer2 != null">#{answer2},</if>
            <if test="parse != null">#{parse},</if>
            <if test="score != null">#{score},</if>
            <if test="qtpye != null">#{qtpye},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSyTestQuestion" parameterType="SyTestQuestion">
        update sy_test_question
        <trim prefix="SET" suffixOverrides=",">
            <if test="paperId != null">paper_id = #{paperId},</if>
            <if test="seq != null">seq = #{seq},</if>
            <if test="title != null">title = #{title},</if>
            <if test="optionA != null">option_a = #{optionA},</if>
            <if test="optionB != null">option_b = #{optionB},</if>
            <if test="optionC != null">option_c = #{optionC},</if>
            <if test="optionD != null">option_d = #{optionD},</if>
            <if test="optionE != null">option_e = #{optionE},</if>
            <if test="valueA != null">value_a = #{valueA},</if>
            <if test="valueB != null">value_b = #{valueB},</if>
            <if test="valueC != null">value_c = #{valueC},</if>
            <if test="valueD != null">value_d = #{valueD},</if>
            <if test="valueE != null">value_e = #{valueE},</if>
            <if test="quesitonCateogry != null">quesiton_cateogry = #{quesitonCateogry},</if>
            <if test="answer1 != null">answer1 = #{answer1},</if>
            <if test="answer2 != null">answer2 = #{answer2},</if>
            <if test="parse != null">parse = #{parse},</if>
            <if test="score != null">score = #{score},</if>
            <if test="qtpye != null">qtpye = #{qtpye},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where question_id = #{questionId}
    </update>

    <delete id="deleteSyTestQuestionById" parameterType="Long">
        delete from sy_test_question where question_id = #{questionId}
    </delete>

    <delete id="deleteSyTestQuestionByIds" parameterType="String">
        delete from sy_test_question where question_id in 
        <foreach item="questionId" collection="array" open="(" separator="," close=")">
            #{questionId}
        </foreach>
    </delete>
</mapper>