|
@@ -143,23 +143,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="listSection" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo" resultMap="SectionStudyRecordVoResult">
|
|
|
SELECT
|
|
|
- DISTINCT r.section_id,
|
|
|
- (select m.module_name FROM course_module m where r.module_id = m.module_id) as module_name,
|
|
|
- (select m.name FROM course_chapter m where r.chapter_id = m.chapter_id) as chapter_name,
|
|
|
- (select m.`name` FROM course_section m where r.section_id = m.section_id) as section_name,
|
|
|
- (select m.duration_time FROM course_section m where r.section_id = m.section_id) as duration_time,
|
|
|
- (select i.start_time FROM user_study_record i where r.section_id = i.section_id ORDER BY i.start_time ASC LIMIT 1) as start_time,
|
|
|
- (select i.end_time FROM user_study_record i where r.section_id = i.section_id ORDER BY i.start_time DESC LIMIT 1) as end_time,
|
|
|
- r.status
|
|
|
+ s.section_id,
|
|
|
+ s.name as section_name,
|
|
|
+ NULL 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 u.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 u.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 u.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ LIMIT 1) as `status`
|
|
|
FROM
|
|
|
- user_study_record r
|
|
|
- LEFT JOIN course c ON c.course_id = r.course_id
|
|
|
- where 1=1
|
|
|
+ course_menu m
|
|
|
+ LEFT JOIN course_section s ON m.menu_id = s.section_id
|
|
|
+ WHERE
|
|
|
+ m.type =3
|
|
|
+ <if test="courseId != null and courseId !=''">
|
|
|
+ and m.course_id={courseId}
|
|
|
+ </if>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ s.section_id,
|
|
|
+ s.name as section_name,
|
|
|
+ (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 r.user_id = #{userId}
|
|
|
+ and u.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 u.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 u.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ LIMIT 1) as `status`
|
|
|
+ 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
|
|
|
+ WHERE
|
|
|
+ m.type =2
|
|
|
<if test="courseId != null and courseId !=''">
|
|
|
- and r.course_id =#{courseId}
|
|
|
+ and m.course_id={courseId}
|
|
|
</if>
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ s.section_id,
|
|
|
+ s.name as section_name,
|
|
|
+ (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 u.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 u.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 u.user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ LIMIT 1) as `status`
|
|
|
+ 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
|
|
|
+ WHERE
|
|
|
+ m.type =1
|
|
|
+ <if test="courseId != null and courseId !=''">
|
|
|
+ and m.course_id={courseId}
|
|
|
+ </if>
|
|
|
+
|
|
|
</select>
|
|
|
</mapper>
|