<?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="cn.reghao.tnb.content.app.exam.db.mapper.QuestionOptionMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into exam_question_option
        (`question_id`,`pos`,`content`,`analysis`,`correct`)
        values 
        (#{questionId},#{pos},#{content},#{analysis},#{correct})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert ignore into exam_question_option
        (`question_id`,`pos`,`content`,`analysis`,`correct`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.questionId},#{item.pos},#{item.content},#{item.analysis},#{item.correct})
        </foreach>
    </insert>

    <delete id="deleteByQuestionId">
        delete from exam_question_option
        where question_id=#{questionId}
    </delete>

    <select id="findAll" resultType="cn.reghao.tnb.content.app.exam.model.po.QuestionOption">
        select *
        from exam_question_option
    </select>
    <select id="findByQuestionId" resultType="cn.reghao.tnb.content.app.exam.model.po.QuestionOption">
        select *
        from exam_question_option
        where question_id=#{questionId}
    </select>
</mapper>
