Blame view

ExerciseCourseTreeMappingMapper.xml 4.52 KB
涂亚平 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
<?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.meishu.mapper.ExerciseCourseTreeMappingMapper">

<!--    &lt;!&ndash; 通用查询映射结果 &ndash;&gt;-->
<!--    <resultMap id="BaseResultMap" type="com.meishu.model.ExerciseCourseTreeMappingDO">-->
<!--        <id column="id" property="id" />-->
<!--        <result column="create_date" property="createTime" />-->
<!--        <result column="update_date" property="updateTime" />-->
<!--        <result column="delete_date" property="deleteTime" />-->
<!--        <result column="exercise_id" property="exerciseId" />-->
<!--        <result column="status" property="status" />-->
<!--    </resultMap>-->

    <!-- 通用查询结果列 -->
    <select id="queryCourseTreeExercise" parameterType="com.meishu.dto.exercise.QueryCourseTreeExerciseDTO" resultType="com.meishu.vo.exercise.QueryCourseTreeExerciseVO">
        SELECT
        t.id,
        t2.exercise_type,
        t2.title,
        t2.items,
        t2.detail,
        t2.right_answer,
        t2.difficulty,
        t3.user_name,
        t.status,
        t2.create_date as update_date,
        t4.right_cnt ,
        t5.total_cnt,
        ROUND(t4.right_cnt/t5.total_cnt,0) as right_percent
        FROM
        exercise_course_tree_mapping t
        LEFT JOIN exercise_dict t2 ON t.exercise_id = t2.id
        LEFT JOIN administer t3 ON t2.administer_id = t3.id
        LEFT JOIN (
        SELECT
        t.course_id,
        t.exercise_id,
        sum( t.result ) AS right_cnt
        FROM
        course_tree_exercise_student_result t
        GROUP BY
        t.course_id,
        t.exercise_id
        ) t4 ON t.exercise_id = t4.exercise_id
        left join (SELECT
        t.course_id,
        t.exercise_id,
        count( t.result ) AS total_cnt
        FROM
        course_tree_exercise_student_result t
        GROUP BY
        t.course_id,
        t.exercise_id) t5 ON  t.exercise_id = t5.exercise_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        <if test="title!=null and title !=''">
            AND t2.title like concat('%',#{title} ,'%')
        </if>
        <if test="exerciseType!=null and exerciseType!=''">
            and exercise_type = #{exerciseType}
        </if>
        <if test="difficulty !=null and difficulty!=''">
            and difficulty = #{difficulty}
        </if>
        <if test="courseTreeId!=null and courseTreeId !=''">
            AND t.course_tree_id = #{courseTreeId}
        </if>
        AND t.course_id = #{courseId}
    </select>

    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, exercise_id, tree_id, status
    </sql>

    <select id="getParentTreeId" parameterType="long" resultType="com.meishu.model.CourseTreeDO">
        SELECT
            t2.*
        FROM
            exercise_course_tree_mapping t
            LEFT JOIN course_tree t2 ON t.course_tree_id = t2.id
        WHERE
            t.id = #{id}
            and t.delete_date is null
            and t2.delete_date is null
    </select>

    <select id="getExercisesByTree" parameterType="com.meishu.dto.course.GetExercisesByTreeDTO" resultType="com.meishu.model.ExerciseDictDO">
        SELECT
            t3.*
        FROM
            exercise_course_tree_mapping t
            LEFT JOIN course_tree t2 ON t.course_tree_id = t2.id
            LEFT JOIN exercise_dict t3 ON t.exercise_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t2.id = #{treeId}
<!--            AND t3.id not IN-->
<!--            <foreach collection="exerciseIds" item="id" index="index" open="(" close=")" separator=",">-->
<!--                #{id}-->
<!--            </foreach>-->
    </select>

    <select id="queryChapterTest" resultType="com.meishu.vo.student.QueryChapterTestVO">
        SELECT
            t2.id,
            t2.title,
            t2.right_answer,
            t2.items,
            t2.difficulty,
            t2.exercise_type,
            t2.detail,
            t2.advice_length,
            t.length,
            t.result,
            t.answer
        FROM
            course_tree_exercise_student_result t
            LEFT JOIN exercise_dict t2 ON t.exercise_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.student_id = #{studentId}
            AND t.chapter_id = #{chapterId}
    </select>

</mapper>