mybatis中使用返回pageData对象,中嵌入一个list

<!--查询试卷试题试卷详情开始-->
    <resultMap id="getStudentExamObjectMap"  type="PageData">
        <id property="id" column="id"/>
        <result property="ExamName" column="ExamName"/>
        <result property="startTime" column="startTime"/>
        <result property="endTime" column="endTime"/>
        <result property="totalTime" column="totalTime"/>
        <result property="description" column="description"/>
        <result property="totalScore" column="totalScore"/>
        <result property="passScore" column="passScore"/>
        <result property="tips" column="tips"/>
        <result property="frequency" column="frequency"/>
        <result property="interval" column="interval"/>
        <result property="leastTime" column="leastTime"/>
        <result property="leastTimeIs" column="leastTimeIs"/>
        <result property="updateTime" column="updateTime"/>

        <collection property="list"  column="{examId=id}"
                    ofType="PageData"  javaType="java.util.ArrayList"   select="getQuestionList">

            <id column="id"  property="id"/>
            <result column="question" property="question"/>
            <result column="answerA" property="answerA"/>
            <result column="answerB" property="answerB"/>
            <result  column="answerC" property="answerC"/>
            <result column="answerD" property="answerD"/>
            <result column="rightAnswer" property="rightAnswer"/>
            <result column="analysis" property="analysis"/>
            <result column="score" property="score"/>
            <result column="type" property="type"/>
        </collection>
    </resultMap>

      <!--查询试卷-->
    <select id="getStudentExamObject" parameterType="PageData" resultMap="getStudentExamObjectMap">
        select em.id,em.exam_name as ExamName,
        DATE_FORMAT(em.start_time, '%Y-%m-%d %H:%i:%s') as startTime, DATE_FORMAT(em.end_time, '%Y-%m-%d %H:%i:%s') as endTime,
        em.total_time as totalTime,em.description as description,
        em.total_score as  totalScore, em.pass_score as passScore, em.tips, em.frequency, em.`interval`,
        em.least_time as leastTime, em.least_time_is as leastTimeIs,  DATE_FORMAT(em.update_time, '%Y-%m-%d') as updateTime from exam_manage as em
        WHERE 1=1
        <if test="examType != null">
            AND em.exam_type = #{examType}
        </if>
        <if test="examId != null">
            AND em.id = #{examId}
        </if>
        and em.is_delete = 0 and em.release=0
    </select>

    <!--查询试卷中试题-->


    <select id="getQuestionList" parameterType="PageData" resultType="PageData">
        SELECT
            q.id, q.question,
            q.answer_a AS answerA, q.answer_b AS answerB, q.answer_c AS answerC, q.answer_d AS answerD,
            q.right_answer AS rightAnswer, q.analysis, q.score, q.type

         FROM
            question q
        RIGHT JOIN paper_manage pm ON q.id = pm.question_id
        WHERE 1=1
        and pm.exam_id = #{examId}
        and  pm.is_delete = 0 and q.is_delete = 0

        order by q.update_time desc
    </select>


    <!--查询试卷试题试卷详情结束-->
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值