<?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.zhongzheng.modules.bank.mapper.QuestionMapper">

    <resultMap type="com.zhongzheng.modules.bank.domain.Question" id="QuestionResult">
        <result property="questionId" column="question_id"/>
        <result property="content" column="content"/>
        <result property="type" column="type"/>
        <result property="answerQuestion" column="answer_question"/>
        <result property="bankSectionId" column="bank_section_id"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="analysisContent" column="analysis_content"/>
        <result property="examId" column="exam_id"/>
        <result property="parentType" column="parent_type"/>
        <result property="imgUrl" column="img_url"/>
        <result property="jsonStr" column="json_str"/>
    </resultMap>

    <select id="selectQuestionSimulateList" parameterType="map"  resultMap="QuestionResult">
        SELECT
            q.*
        FROM
            question_bank qb
                LEFT JOIN question_bank_chapter qbc
                          on qb.bank_id = qbc.bank_id
                LEFT JOIN question_bank_section qbs
                          on qbc.bank_chapter_id = qbs.bank_chapter_id
                LEFT JOIN question q
                          on qbs.bank_section_id = q.bank_section_id
        WHERE
            qb.bank_id = #{bankId}
          AND type = #{type}
        ORDER BY
            RAND()
            LIMIT #{num}
    </select>
</mapper>
