<?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.ExmExamQuestionMapper">
    
    <resultMap type="ExmExamQuestion" id="ExmExamQuestionResult">
        <result property="id"    column="ID"    />
        <result property="chapterName"    column="CHAPTER_NAME"    />
        <result property="chapterTxt"    column="CHAPTER_TXT"    />
        <result property="type"    column="TYPE"    />
        <result property="score"    column="SCORE"    />
        <result property="scores"    column="SCORES"    />
        <result property="markOptions"    column="MARK_OPTIONS"    />
        <result property="examId"    column="EXAM_ID"    />
        <result property="questionId"    column="QUESTION_ID"    />
        <result property="no"    column="NO"    />
        <result property="optionsNo"    column="OPTIONS_NO"    />
        <result property="updateUserId"    column="UPDATE_USER_ID"    />
        <result property="updateTime"    column="UPDATE_TIME"    />
    </resultMap>

    <sql id="selectExmExamQuestionVo">
        select ID, CHAPTER_NAME, CHAPTER_TXT, TYPE, SCORE, SCORES, MARK_OPTIONS, EXAM_ID, QUESTION_ID, NO, OPTIONS_NO, UPDATE_USER_ID, UPDATE_TIME from exm_exam_question
    </sql>

    <select id="selectExmExamQuestionList" parameterType="ExmExamQuestion" resultMap="ExmExamQuestionResult">
        <include refid="selectExmExamQuestionVo"/>
        <where>  
            <if test="chapterName != null  and chapterName != ''"> and CHAPTER_NAME like concat('%', #{chapterName}, '%')</if>
            <if test="chapterTxt != null  and chapterTxt != ''"> and CHAPTER_TXT = #{chapterTxt}</if>
            <if test="type != null "> and TYPE = #{type}</if>
            <if test="score != null "> and SCORE = #{score}</if>
            <if test="scores != null  and scores != ''"> and SCORES = #{scores}</if>
            <if test="markOptions != null  and markOptions != ''"> and MARK_OPTIONS = #{markOptions}</if>
            <if test="examId != null "> and EXAM_ID = #{examId}</if>
            <if test="questionId != null "> and QUESTION_ID = #{questionId}</if>
            <if test="no != null "> and NO = #{no}</if>
            <if test="optionsNo != null  and optionsNo != ''"> and OPTIONS_NO = #{optionsNo}</if>
            <if test="updateUserId != null "> and UPDATE_USER_ID = #{updateUserId}</if>
            <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectExmExamQuestionById" parameterType="Long" resultMap="ExmExamQuestionResult">
        <include refid="selectExmExamQuestionVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertExmExamQuestion" parameterType="ExmExamQuestion" useGeneratedKeys="true" keyProperty="id">
        insert into exm_exam_question
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="chapterName != null">CHAPTER_NAME,</if>
            <if test="chapterTxt != null">CHAPTER_TXT,</if>
            <if test="type != null">TYPE,</if>
            <if test="score != null">SCORE,</if>
            <if test="scores != null">SCORES,</if>
            <if test="markOptions != null">MARK_OPTIONS,</if>
            <if test="examId != null">EXAM_ID,</if>
            <if test="questionId != null">QUESTION_ID,</if>
            <if test="no != null">NO,</if>
            <if test="optionsNo != null">OPTIONS_NO,</if>
            <if test="updateUserId != null">UPDATE_USER_ID,</if>
            <if test="updateTime != null">UPDATE_TIME,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="chapterName != null">#{chapterName},</if>
            <if test="chapterTxt != null">#{chapterTxt},</if>
            <if test="type != null">#{type},</if>
            <if test="score != null">#{score},</if>
            <if test="scores != null">#{scores},</if>
            <if test="markOptions != null">#{markOptions},</if>
            <if test="examId != null">#{examId},</if>
            <if test="questionId != null">#{questionId},</if>
            <if test="no != null">#{no},</if>
            <if test="optionsNo != null">#{optionsNo},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateExmExamQuestion" parameterType="ExmExamQuestion">
        update exm_exam_question
        <trim prefix="SET" suffixOverrides=",">
            <if test="chapterName != null">CHAPTER_NAME = #{chapterName},</if>
            <if test="chapterTxt != null">CHAPTER_TXT = #{chapterTxt},</if>
            <if test="type != null">TYPE = #{type},</if>
            <if test="score != null">SCORE = #{score},</if>
            <if test="scores != null">SCORES = #{scores},</if>
            <if test="markOptions != null">MARK_OPTIONS = #{markOptions},</if>
            <if test="examId != null">EXAM_ID = #{examId},</if>
            <if test="questionId != null">QUESTION_ID = #{questionId},</if>
            <if test="no != null">NO = #{no},</if>
            <if test="optionsNo != null">OPTIONS_NO = #{optionsNo},</if>
            <if test="updateUserId != null">UPDATE_USER_ID = #{updateUserId},</if>
            <if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteExmExamQuestionById" parameterType="Long">
        delete from exm_exam_question where ID = #{id}
    </delete>

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