<?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.basic.mapper.QuestionAnswerDetailMapper">
    <insert id="insertBatch">
        INSERT INTO question_answer_detail (sheet_id, question_id, option_id) VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.sheetId}, #{item.questionId}, #{item.optionId})
        </foreach>
    </insert>

    <select id="getBySheetId" resultType="com.ruoyi.basic.domain.question.QuestionAnswerDetail">
        select
            * ,
            (select score from question_option where question_id = question_answer_detail.question_id and id = question_answer_detail.option_id) as score
        from question_answer_detail where sheet_id = #{sheetId}
    </select>
</mapper>
