LiveClassesMapper.xml 3.42 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.LiveClassesMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.LiveClassesDO">
        <id column="id" property="id" />
        <result column="create_date" property="createDate" />
        <result column="update_date" property="updateDate" />
        <result column="delete_date" property="deleteDate" />
        <result column="live_id" property="liveId" />
        <result column="class_id" property="classId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, live_id, class_id
    </sql>

    <select id="classMembers" resultType="com.subsidy.vo.live.ClassMembersVO">
        SELECT
           t.id,
            t.telephone,
            t.user_name,
            t2.play_length
        FROM
            (
            SELECT
               distinct t2.id,
                t2.user_name,
                t2.telephone
            FROM
                class_member_mapping t
                LEFT JOIN member t2 ON t.member_id = t2.id
                LEFT JOIN live_classes t3 ON t.class_id = t3.class_id
            WHERE
                t.delete_date IS NULL
                AND t2.delete_date IS NULL
                AND t3.delete_date IS NULL
                AND t.class_id = #{classId}
                AND t3.live_id = #{liveId}
                <if test="userName != null and userName != ''">
                    and t2.user_name like concat('%',#{userName} ,'%')
                </if>
            ) t
            LEFT JOIN (
            SELECT
                t.live_id,
                t.member_id,
                sum( t.play_duration ) AS play_length
            FROM
                live_study_history t
            WHERE
                t.delete_date IS NULL
                AND t.live_id = #{liveId}
            GROUP BY
                t.live_id,
            t.member_id
            ) t2 ON t.id = t2.member_id
    </select>

    <select id="liveMemberCounts" parameterType="long" resultType="integer">
        SELECT
            count(
            DISTINCT ( t2.member_id ))
        FROM
            live_classes t
            LEFT JOIN class_member_mapping t2 ON t.class_id = t2.class_id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.live_id = #{liveId}
            and t2.class_id = #{classId}
    </select>

    <select id="liveActualCounts" parameterType="long" resultType="integer">
        SELECT
            count(
            DISTINCT ( t.member_id ))
        FROM
            live_study_history t
            left join class_member_mapping t2 on t.member_id = t2.member_id
        WHERE
            t.delete_date is null
            and t2.delete_date is null
            AND t.live_id = #{liveId}
            and t2.class_id = #{classId}
    </select>

    <select id="classLives" parameterType="long" resultType="com.subsidy.vo.live.ClassLivesVO">
        SELECT
            distinct t2.id,
            t2.live_name
        FROM
            live_classes t
            LEFT JOIN live_dict t2 ON t.live_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t.class_id = #{classId}
    </select>

</mapper>