PaperDictMapper.xml 3.19 KB
<?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.subsidy.mapper.PaperDictMapper">

    <select id="queryPapers" parameterType="com.subsidy.model.PaperDictDO" resultType="com.subsidy.vo.paper.QueryPapersVO">
        SELECT
            t.id,
            t2.vod_name,
            paper_name,
            paper_status
        FROM
            paper_dict t
            left join vod_dict t2 on t.vod_id = t2.id
        WHERE
            t.delete_date is null
            and t.course_id = #{courseId}
        <if  test="paperName != null and paperName !=''">
            AND t.paper_name LIKE concat('%',#{paperName} ,'%')
        </if>
        <if test="paperStatus != null and paperStatus !=''">
            AND t.paper_status = #{paperStatus}
        </if>
    </select>

    <select id="completeCount"  resultType="integer">
        SELECT
            count( DISTINCT t.member_id ) AS cnt
        FROM
            exercise_done_result t
        WHERE
            t.delete_date IS NULL
            AND t.paper_id = #{paperId}
            and t.class_id = #{classId}
    </select>

    <select id="queryCoursePapersCnt" parameterType="long" resultType="integer">
        SELECT
            count( 1 )
        FROM
            paper_dict t
        WHERE
            t.delete_date IS NULL
            AND t.course_id = #{courseId}
    </select>

    <select id="memberMaxScore" resultType="com.subsidy.vo.paper.MemberMaxScoreVO">
        SELECT
            t4.right_counts,
            t4.total_counts,
            t4.result,
            t3.paper_id
        FROM
            (
            SELECT
                t.class_id,
                t.paper_id,
                t.member_id,
                t2.paper_name,
                max( score ) AS score
            FROM
                exercise_done_result t
                LEFT JOIN paper_dict t2 ON t.paper_id = t2.id
            WHERE
                t.delete_date IS NULL
                AND t2.delete_date IS NULL
                AND t.class_id = #{classId}
                AND t2.vod_id = #{vodId}
                AND t.member_id = #{memberId}
            GROUP BY
                t.class_id,
                t.paper_id,
                t.member_id,
                t2.paper_name
            ) t3
            LEFT JOIN exercise_done_result t4 ON t3.score = t4.score
            AND t3.member_id = t4.member_id
            AND t3.paper_id = t4.paper_id
            AND t3.class_id = t4.class_id
            LIMIT 1
    </select>

    <select id="lastPaper" parameterType="long" resultType="long">
        SELECT
            t4.*
        FROM
            course_content t
            LEFT JOIN content_vod_mapping t2 ON t.id = t2.content_id
            LEFT JOIN vod_dict t3 ON t2.vod_id = t3.id
            LEFT JOIN paper_dict t4 ON t.course_id = t4.course_id
            AND t4.vod_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            AND t4.delete_date IS NULL
            AND t.course_id = #{courseId}
        ORDER BY
            t2.order_no DESC,
            t3.id DESC
    </select>
</mapper>