<?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.QuestionInfoMapper">
    
    <resultMap type="QuestionInfo" id="QuestionInfoResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="type"    column="type"    />
        <result property="descripiton"    column="descripiton"    />
        <result property="itemList"    column="item_list"    />
        <result property="correctItem"    column="correct_item"    />
        <result property="analysis"    column="analysis"    />
        <result property="categoryId"    column="category_id"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectQuestionInfoVo">
        select id, title, type, descripiton, item_list, correct_item, analysis, category_id, remark, create_time, update_time, create_by, update_by from question_info
    </sql>

    <select id="selectQuestionInfoList" parameterType="QuestionInfo" resultMap="QuestionInfoResult">
        <include refid="selectQuestionInfoVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="descripiton != null  and descripiton != ''"> and descripiton = #{descripiton}</if>
            <if test="itemList != null  and itemList != ''"> and item_list = #{itemList}</if>
            <if test="correctItem != null  and correctItem != ''"> and correct_item = #{correctItem}</if>
            <if test="analysis != null  and analysis != ''"> and analysis = #{analysis}</if>
            <if test="categoryId != null  and categoryId != ''"> and category_id = #{categoryId}</if>
        </where>
    </select>
    
    <select id="selectQuestionInfoById" parameterType="Long" resultMap="QuestionInfoResult">
        <include refid="selectQuestionInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertQuestionInfo" parameterType="QuestionInfo" useGeneratedKeys="true" keyProperty="id">
        insert into question_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="type != null">type,</if>
            <if test="descripiton != null">descripiton,</if>
            <if test="itemList != null">item_list,</if>
            <if test="correctItem != null">correct_item,</if>
            <if test="analysis != null">analysis,</if>
            <if test="categoryId != null">category_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="type != null">#{type},</if>
            <if test="descripiton != null">#{descripiton},</if>
            <if test="itemList != null">#{itemList},</if>
            <if test="correctItem != null">#{correctItem},</if>
            <if test="analysis != null">#{analysis},</if>
            <if test="categoryId != null">#{categoryId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateQuestionInfo" parameterType="QuestionInfo">
        update question_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="type != null">type = #{type},</if>
            <if test="descripiton != null">descripiton = #{descripiton},</if>
            <if test="itemList != null">item_list = #{itemList},</if>
            <if test="correctItem != null">correct_item = #{correctItem},</if>
            <if test="analysis != null">analysis = #{analysis},</if>
            <if test="categoryId != null">category_id = #{categoryId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQuestionInfoById" parameterType="Long">
        delete from question_info where id = #{id}
    </delete>

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