<?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.yanzhu.manage.mapper.BusExamQuestionResultMapper">
    
    <resultMap type="BusExamQuestionResult" id="BusExamQuestionResultResult">
        <result property="id"    column="id"    />
        <result property="questionId"    column="question_id"    />
        <result property="opt"    column="opt"    />
        <result property="result"    column="result"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBusExamQuestionResultVo">
        select id, question_id, opt, result, is_del, create_by, create_time, update_by, update_time, remark from bus_exam_question_result
    </sql>

    <select id="selectBusExamQuestionResultList" parameterType="BusExamQuestionResult" resultMap="BusExamQuestionResultResult">
        <include refid="selectBusExamQuestionResultVo"/>
        <where>  
            <if test="questionId != null "> and question_id = #{questionId}</if>
            <if test="opt != null  and opt != ''"> and opt = #{opt}</if>
            <if test="result != null  and result != ''"> and result like concat('%', #{result}, '%')</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectBusExamQuestionResultById" parameterType="Long" resultMap="BusExamQuestionResultResult">
        <include refid="selectBusExamQuestionResultVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusExamQuestionResult" parameterType="BusExamQuestionResult" useGeneratedKeys="true" keyProperty="id">
        insert into bus_exam_question_result
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="questionId != null">question_id,</if>
            <if test="opt != null">opt,</if>
            <if test="result != null">result,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="questionId != null">#{questionId},</if>
            <if test="opt != null">#{opt},</if>
            <if test="result != null">#{result},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBusExamQuestionResult" parameterType="BusExamQuestionResult">
        update bus_exam_question_result
        <trim prefix="SET" suffixOverrides=",">
            <if test="questionId != null">question_id = #{questionId},</if>
            <if test="opt != null">opt = #{opt},</if>
            <if test="result != null">result = #{result},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusExamQuestionResultById" parameterType="Long">
        delete from bus_exam_question_result where id = #{id}
    </delete>

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