Administrator
2021-08-03 372ec8892f5ed3d11736e75abdd7f33ea34e0d2d
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
@@ -5,19 +5,68 @@
    <resultMap id="PagerSubject" type="org.springblade.modules.exam.vo.ExamPaperSubjectVO"
               autoMapping="true">
        <id property="id" column="id"/>
        <collection property="examExaminationSubjects" javaType="java.util.List" ofType="org.springblade.modules.exam.entity.ExamExaminationSubject" autoMapping="true">
        <collection property="examExaminationSubjects" javaType="java.util.List"
                    ofType="org.springblade.modules.exam.entity.ExamExaminationSubject" autoMapping="true">
            <id property="id" column="tid"/>
            <association property="examSubjectChoices" javaType="org.springblade.modules.exam.entity.ExamSubjectChoices" autoMapping="true">
            <association property="examSubjectChoices" javaType="org.springblade.modules.exam.entity.ExamSubjectChoices"
                         resultMap="brakesResult" autoMapping="true">
            </association>
        </collection>
    </resultMap>
    <resultMap id="PagerSubjectAnswer" type="org.springblade.modules.exam.vo.ExamPaperSubjectVO"
               autoMapping="true">
        <id property="id" column="id"/>
        <collection property="examExaminationSubjects" javaType="java.util.List"
                    ofType="org.springblade.modules.exam.entity.ExamExaminationSubject" autoMapping="true">
            <id property="id" column="tid"/>
            <association property="examSubjectChoices" javaType="org.springblade.modules.exam.entity.ExamSubjectChoices"
                         autoMapping="true">
                <id property="id" column="sid"/>
            </association>
        </collection>
    </resultMap>
    <resultMap id="brakesResult" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        <id property="id" column="sid"/>
        <id property="categoryId" column="category_id"/>
        <id property="subjectName" column="subject_name"/>
        <id property="choicesType" column="choices_type"/>
        <id property="score" column="score"/>
        <id property="analysis" column="analysis"/>
        <id property="level" column="level"/>
        <id property="creator" column="creator"/>
        <id property="createDate" column="create_date"/>
        <id property="modifier" column="modifier"/>
        <id property="modifyDate" column="modify_date"/>
        <id property="delFlag" column="del_flag"/>
        <id property="applicationCode" column="application_code"/>
        <id property="tenantCode" column="tenant_code"/>
    </resultMap>
    <resultMap id="RandomResult" type="org.springblade.modules.exam.vo.ExamSubjectChoicesVO">
        <id property="id" column="id"/>
        <id property="categoryId" column="category_id"/>
        <id property="subjectName" column="subject_name"/>
        <id property="choicesType" column="choices_type"/>
        <id property="score" column="score"/>
        <id property="answer" column=""/>
        <id property="analysis" column="analysis"/>
        <id property="level" column="level"/>
        <id property="creator" column="creator"/>
        <id property="createDate" column="create_date"/>
        <id property="modifier" column="modifier"/>
        <id property="modifyDate" column="modify_date"/>
        <id property="delFlag" column="del_flag"/>
        <id property="applicationCode" column="application_code"/>
        <id property="tenantCode" column="tenant_code"/>
    </resultMap>
    <select id="queryPagerSubject" resultMap="PagerSubject">
        SELECT
        sj.*,
        tm.id tid,
        tmxq.id as sid,tmxq.subject_name,tmxq.answer,tmxq.analysis
        tmxq.id as sid,tmxq.*
        FROM
        ksxt_exam sj
        LEFT JOIN exam_examination_subject tm ON sj.id = tm.examination_id
@@ -25,8 +74,101 @@
        WHERE
        1 = 1
        <if test="paper.id !=null">
        and sj.id = #{paper.id}
            and sj.id = #{paper.id}
        </if>
    </select>
    <select id="queryRandomSubject" resultMap="RandomResult" >
        SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 0 ORDER BY RAND( ) LIMIT 50 ) a UNION ALL
        SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 1 ORDER BY RAND( ) LIMIT 20 ) b UNION ALL
        SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 2 ORDER BY RAND( ) LIMIT 20 ) c UNION ALL
        SELECT * FROM ( SELECT * FROM exam_subject_choices WHERE choices_type = 3 ORDER BY RAND( ) LIMIT 5 ) d
    </select>
    <select id="selectExamPaperPage" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
        SELECT
            *
        FROM
            (SELECT
                sj.*,
                ( SELECT CASE WHEN COUNT ( * ) > 0 THEN 1 ELSE 0 END FROM sys_apply WHERE user_id = 11 ) AS show
            FROM
                ksxt_exam sj ) as s
        WHERE
            show = 1
    </select>
    <select id="PagerSubject" resultMap="PagerSubjectAnswer">
        SELECT
        sj.*,
        tm.id tid,
        tmxq.id as sid,tmxq.*
        FROM
        ksxt_exam sj
        LEFT JOIN exam_examination_subject tm ON sj.id = tm.examination_id
        LEFT JOIN exam_subject_choices tmxq ON tm.subject_id = tmxq.id
        WHERE
        1 = 1
        <if test="paper.id !=null">
            and sj.id = #{paper.id}
        </if>
    </select>
    <!--自定义树-->
    <select id="selectExamPaperPageTree" resultType="org.springblade.modules.exam.entity.ExamPaper">
        select id,exam_name examName from ksxt_exam
        where
        1=1
        <if test="paper.examName!=null and paper.examName!=''">
            and exam_name like concat('%', #{paper.examName},'%')
        </if>
    </select>
    <delete id="UnbindSubject">
       delete from exam_examination_subject where examination_id = #{paperid} and subject_id = #{subjectid}
    </delete>
    <!--查询考试人员考试信息-->
    <select id="getExamDetail" resultType="org.springblade.modules.exam.vo.ExamPaperVO">
        (select
            ke.id,ke.exam_name examName,
            sa.candidate_no candidateNo,
            bu.real_name realName,bu.sex
        from
            ksxt_exam ke
        left join
            sys_apply sa
        on
            sa.exam_id = ke.id
        left join
            blade_user bu
        on
            bu.id = sa.user_id
        where sa.user_id = #{userId}
        and is_exam = 1
        and sa.apply_status = 2
        )
        union all
        (select
            ke.id,ke.exam_name examName,
            str.candidate_no candidateNo,
            bu.real_name realName,bu.sex
        from
            ksxt_exam ke
        left join
            sys_training_registration str
        on
            str.train_exam_id = ke.id
        left join
            blade_user bu
        on
            bu.id = str.user_id
        where str.user_id = #{userId}
        and is_exam = 1
        and str.cancel = 3
        )
    </select>
</mapper>