<?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.school.paper.mapper.DbQuestionBankTestPaperMapper">

    <resultMap type="com.ruoyi.school.paper.domain.DbQuestionBankTestPaper" id="DbQuestionBankTestPaperResult">
        <result property="id" column="id"/>
        <result property="testPaperId" column="test_paper_id"/>
        <result property="categoryId" column="category_id"/>
        <result property="species" column="species"/>
        <result property="phaseId" column="phase_id"/>
        <result property="type" column="type"/>
        <result property="intensity" column="intensity"/>
        <result property="topic" column="topic"/>
        <result property="rightAnswers" column="right_answers"/>
        <result property="rightAnswersPic" column="right_answers_pic"/>
        <result property="resolveCourse" column="resolve_course"/>
        <result property="resolveVideo" column="resolve_video"/>
        <result property="remark" column="remark"/>
        <result property="status" column="status"/>
        <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>

    <resultMap id="TestPaper" type="com.ruoyi.school.paper.domain.vo.TestQuestionItemVo">
        <id property="id" column="id"/>
        <result property="topic" column="topic"/>
        <result property="species" column="species"/>
        <collection property="options" column="id" ofType="com.ruoyi.school.paper.domain.vo.OptionsVo" select="selectOptions">
            <result property="optionTag" column="option_tag"/>
            <result property="optionContent" column="option_content"/>
        </collection>
    </resultMap>

    <select id="selectOptions" resultType="com.ruoyi.school.paper.domain.vo.OptionsVo">
        select options.option_tag, options.option_content
        from db_question_bank_answer_test_paper as options
        where options.question_bank_id = #{id}
    </select>

    <select id="selectTestPaperQuestion" resultMap="TestPaper">
        select question_bank.id,
               question_bank.topic,
               question_bank.species
        from db_test_paper_record as answer_sheet
                 join db_question_bank_test_paper as question_bank
                      on answer_sheet.test_paper_id = question_bank.test_paper_id
        where answer_sheet.id = #{condition.recordId}
    </select>


</mapper>
