|
@@ -118,7 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="listSubject" parameterType="com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo" resultMap="SubjectStudyRecordVoResult">
|
|
|
SELECT
|
|
|
- u.user_id,
|
|
|
+ #{userId} as user_id,
|
|
|
r.subject_id,
|
|
|
r.course_id,
|
|
|
r.course_name,
|
|
@@ -127,15 +127,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
(SELECT COUNT(id) FROM course_menu m where m.course_id = r.course_id and m.type in(1)) as module_num,
|
|
|
(SELECT COUNT(id)+(SELECT COUNT(p.id) FROM course_module_chapter p LEFT JOIN course_menu m on m.menu_id = p.module_id where m.course_id = r.course_id and m.type in(1)) FROM course_menu m where m.course_id = r.course_id and m.type in(2)) as chapter_num,
|
|
|
(SELECT COUNT(id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id where m.course_id = r.course_id and m.type in(1))+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_menu m on m.menu_id = n.chapter_id where m.course_id = r.course_id and m.type in(2)) FROM course_menu m where m.course_id = r.course_id and m.type in(3)) as section_num,
|
|
|
- (select COUNT(DISTINCT record_id) FROM user_study_record c where c.course_id = r.course_id and c.status = 1) as record_num
|
|
|
+ (select COUNT(DISTINCT record_id) FROM user_study_record c where c.course_id = r.course_id and c.user_id=#{userId} and c.status = 1) as record_num
|
|
|
FROM
|
|
|
- goods_course c
|
|
|
- LEFT JOIN course r ON c.course_id = r.course_id
|
|
|
- LEFT JOIN user_study_record u on u.course_id = r.course_id
|
|
|
+ course r
|
|
|
+ LEFT JOIN goods_course c ON c.course_id = r.course_id
|
|
|
where 1=1
|
|
|
- <if test="userId != null and userId !=''">
|
|
|
- and u.user_id = #{userId}
|
|
|
- </if>
|
|
|
<if test="goodId != null and goodId !=''">
|
|
|
and c.goods_id =#{goodId}
|
|
|
</if>
|
|
@@ -150,17 +146,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
|
+ 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 u.user_id = #{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 u.user_id = #{userId}
|
|
|
+ and i.user_id = #{userId}
|
|
|
</if>
|
|
|
LIMIT 1) as `status`
|
|
|
FROM
|
|
@@ -169,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
WHERE
|
|
|
m.type =3
|
|
|
<if test="courseId != null and courseId !=''">
|
|
|
- and m.course_id={courseId}
|
|
|
+ and m.course_id=#{courseId}
|
|
|
</if>
|
|
|
UNION
|
|
|
SELECT
|
|
@@ -180,17 +176,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
|
+ 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 u.user_id = #{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 u.user_id = #{userId}
|
|
|
+ and i.user_id = #{userId}
|
|
|
</if>
|
|
|
LIMIT 1) as `status`
|
|
|
FROM
|
|
@@ -200,7 +196,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
WHERE
|
|
|
m.type =2
|
|
|
<if test="courseId != null and courseId !=''">
|
|
|
- and m.course_id={courseId}
|
|
|
+ and m.course_id=#{courseId}
|
|
|
</if>
|
|
|
UNION
|
|
|
SELECT
|
|
@@ -211,17 +207,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
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}
|
|
|
+ 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 u.user_id = #{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 u.user_id = #{userId}
|
|
|
+ and i.user_id = #{userId}
|
|
|
</if>
|
|
|
LIMIT 1) as `status`
|
|
|
FROM
|
|
@@ -232,7 +228,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
WHERE
|
|
|
m.type =1
|
|
|
<if test="courseId != null and courseId !=''">
|
|
|
- and m.course_id={courseId}
|
|
|
+ and m.course_id=#{courseId}
|
|
|
</if>
|
|
|
|
|
|
</select>
|