Browse Source

fix 系统选新班

he2802 3 years ago
parent
commit
41d967a634

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/SectionStudyRecordVo.java

@@ -49,6 +49,7 @@ public class SectionStudyRecordVo {
     @ApiModelProperty("是否完成 1完成 0 未完成 2學習中")
     private Long status;
 
-
+    @ApiModelProperty("学习时长")
+    private Long videoCurrentTime;
 
 }

+ 44 - 31
zhongzheng-system/src/main/resources/mapper/modules/user/UserStudyRecordMapper.xml

@@ -63,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="startTime" column="start_time"/>
         <result property="endTime" column="end_time"/>
         <result property="status" column="status"/>
+        <result property="videoCurrentTime" column="video_current_time"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.user.vo.ExamStudyRecordVo" id="ExamStudyRecordVoResult">
@@ -190,7 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             course_menu m
             LEFT JOIN course_section s ON m.menu_id = s.section_id
-        LEFT JOIN (SELECT
+        RIGHT JOIN (SELECT
         any_value ( usr.first_start_time ) start_time,
         any_value ( usr.video_current_time ) video_current_time,
         any_value ( usr.end_time ) end_time,
@@ -219,25 +220,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             (SELECT t.`name` FROM course_chapter t where m.menu_id = t.chapter_id ) as chapter_name,
             NULL as module_name,
             s.duration_time,
-        (select i.start_time FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        ORDER BY i.start_time ASC LIMIT 1) as start_time,
-        (select i.end_time FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        ORDER BY i.start_time DESC LIMIT 1) as end_time,
-        (select i.`status` FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        LIMIT 1) as `status`
+        usr1.start_time,
+        usr1.end_time,
+        usr1.`status`,
+        usr1.video_current_time
         FROM
             course_chapter_section c
             LEFT JOIN course_menu m on m.menu_id = c.chapter_id
             LEFT JOIN course_section s ON c.section_id = s.section_id
+            RIGHT JOIN (SELECT
+            any_value ( usr.first_start_time ) start_time,
+            any_value ( usr.video_current_time ) video_current_time,
+            any_value ( usr.end_time ) end_time,
+            any_value ( usr.`status` ) `status`,
+            any_value ( usr.section_id ) section_id
+            FROM
+            ( SELECT * FROM user_study_record WHERE 1=1
+            <if test="userId != null and userId !=''">
+                AND user_id = #{userId}
+            </if>
+            <if test="userId != null and userId !=''">
+                AND goods_id = #{goodsId}
+            </if>
+            AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
+            GROUP BY
+            usr.section_id) usr1 on m.menu_id = usr1.section_id
         WHERE
             m.type =2
         <if test="courseId != null and courseId !=''">
@@ -250,26 +257,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             (SELECT t.`name` FROM course_chapter t where e.chapter_id = t.chapter_id ) as chapter_name,
             (SELECT t.module_name FROM course_module t where e.module_id = t.module_id ) as module_name,
             s.duration_time,
-        (select i.start_time FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        ORDER BY i.start_time ASC LIMIT 1) as start_time,
-        (select i.end_time FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        ORDER BY i.start_time DESC LIMIT 1) as end_time,
-        (select i.`status` FROM user_study_record i where m.menu_id = i.section_id
-        <if test="userId != null and userId !=''">
-            and i.user_id = #{userId}
-        </if>
-        LIMIT 1) as `status`
+        usr1.start_time,
+        usr1.end_time,
+        usr1.`status`,
+        usr1.video_current_time
         FROM
             course_chapter_section c
             LEFT JOIN course_module_chapter e on c.chapter_id = e.chapter_id
             LEFT JOIN course_menu m on m.menu_id = e.module_id
             LEFT JOIN course_section s ON c.section_id = s.section_id
+        RIGHT JOIN (SELECT
+        any_value ( usr.first_start_time ) start_time,
+        any_value ( usr.video_current_time ) video_current_time,
+        any_value ( usr.end_time ) end_time,
+        any_value ( usr.`status` ) `status`,
+        any_value ( usr.section_id ) section_id
+        FROM
+        ( SELECT * FROM user_study_record WHERE 1=1
+        <if test="userId != null and userId !=''">
+            AND user_id = #{userId}
+        </if>
+        <if test="userId != null and userId !=''">
+            AND goods_id = #{goodsId}
+        </if>
+        AND course_id = #{courseId} ORDER BY record_id DESC LIMIT 9999 ) usr
+        GROUP BY
+        usr.section_id) usr1 on m.menu_id = usr1.section_id
         WHERE
             m.type =1
         <if test="courseId != null and courseId !=''">