<?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.ExmQuestionTypeMapper">
    
    <resultMap type="ExmQuestionType" id="ExmQuestionTypeResult">
        <result property="id"    column="ID"    />
        <result property="name"    column="NAME"    />
        <result property="createUserId"    column="CREATE_USER_ID"    />
        <result property="updateUserId"    column="UPDATE_USER_ID"    />
        <result property="updateTime"    column="UPDATE_TIME"    />
    </resultMap>

    <sql id="selectExmQuestionTypeVo">
        select ID, NAME, CREATE_USER_ID, UPDATE_USER_ID, UPDATE_TIME from exm_question_type
    </sql>

    <select id="selectExmQuestionTypeList" parameterType="ExmQuestionType" resultMap="ExmQuestionTypeResult">
        <include refid="selectExmQuestionTypeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and NAME like concat('%', #{name}, '%')</if>
            <if test="createUserId != null "> and CREATE_USER_ID = #{createUserId}</if>
            <if test="updateUserId != null "> and UPDATE_USER_ID = #{updateUserId}</if>
            <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectExmQuestionTypeById" parameterType="Long" resultMap="ExmQuestionTypeResult">
        <include refid="selectExmQuestionTypeVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertExmQuestionType" parameterType="ExmQuestionType" useGeneratedKeys="true" keyProperty="id">
        insert into exm_question_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">NAME,</if>
            <if test="createUserId != null">CREATE_USER_ID,</if>
            <if test="updateUserId != null">UPDATE_USER_ID,</if>
            <if test="updateTime != null">UPDATE_TIME,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateExmQuestionType" parameterType="ExmQuestionType">
        update exm_question_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">NAME = #{name},</if>
            <if test="createUserId != null">CREATE_USER_ID = #{createUserId},</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="deleteExmQuestionTypeById" parameterType="Long">
        delete from exm_question_type where ID = #{id}
    </delete>

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