123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- <?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.zhongzheng.modules.course.mapper.CourseMenuMapper">
- <resultMap type="com.zhongzheng.modules.course.domain.CourseMenu" id="CourseMenuResult">
- <result property="id" column="id"/>
- <result property="courseId" column="course_id"/>
- <result property="menuId" column="menu_id"/>
- <result property="type" column="type"/>
- <result property="parentId" column="parent_id"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="status" column="status"/>
- <result property="sort" column="sort"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.course.vo.CourseMenuVo" id="CourseMenuResultVo">
- <result property="id" column="id"/>
- <result property="courseId" column="course_id"/>
- <result property="menuId" column="menu_id"/>
- <result property="type" column="type"/>
- <result property="parentId" column="parent_id"/>
- <result property="status" column="status"/>
- <result property="menuName" column="menu_name"/>
- <result property="durationTime" column="duration_time"/>
- <result property="sort" column="sort"/>
- <result property="sectionType" column="section_type"/>
- <result property="liveStartTime" column="live_start_time"/>
- <result property="liveEndTime" column="live_end_time"/>
- <result property="recordingUrl" column="recording_url"/>
- <result property="liveUrl" column="live_url"/>
- <result property="examType" column="exam_type"/>
- <result property="freeExamId" column="free_exam_id"/>
- <result property="freeExamName" column="free_exam_name"/>
- <result property="code" column="code"/>
- <result property="publishStatus" column="publish_status"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.course.vo.CourseUserMenuVo" id="CourseUserMenuVo">
- <result property="id" column="id"/>
- <result property="courseId" column="course_id"/>
- <result property="gradeId" column="grade_id"/>
- <result property="menuId" column="menu_id"/>
- <result property="type" column="type"/>
- <result property="parentId" column="parent_id"/>
- <result property="status" column="status"/>
- <result property="menuName" column="menu_name"/>
- <result property="durationTime" column="duration_time"/>
- <result property="sort" column="sort"/>
- <result property="sectionType" column="section_type"/>
- <result property="liveStartTime" column="live_start_time"/>
- <result property="liveEndTime" column="live_end_time"/>
- <result property="recordingUrl" column="recording_url"/>
- <result property="liveUrl" column="live_url"/>
- <result property="teacherName" column="teacher_name"/>
- <result property="goodsId" column="goods_id"/>
- </resultMap>
- <select id="getList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseMenuResultVo">
- SELECT * from (SELECT
- m.*,
- cm.module_name AS menu_name,
- cm.publish_status AS publish_status,
- cm.code AS code,
- 0 AS duration_time,
- NULL AS section_type,
- NULL AS live_start_time,
- NULL AS live_end_time,
- NULL AS live_url,
- NULL AS recording_url,
- cm.exam_type AS exam_type,
- cm.free_exam_id AS free_exam_id,
- (
- CASE
- cm.exam_type
- WHEN 1 THEN
- ( SELECT module_name FROM question_module WHERE module_exam_id = cm.free_exam_id )
- WHEN 2 THEN
- ( SELECT `name` FROM question_chapter WHERE chapter_exam_id = cm.free_exam_id )
- WHEN 3 THEN
- ( SELECT exam_name FROM exam WHERE exam_id = cm.free_exam_id ) ELSE ( NULL )
- END
- ) free_exam_name
- FROM
- course_menu m
- LEFT JOIN course_module cm ON m.menu_id = cm.module_id
- WHERE
- m.course_id = #{courseId}
- AND m.type = 1 and cm.`status`!=-1
- UNION
- SELECT
- m.*,
- cc.`name` AS menu_name,
- cc.publish_status AS publish_status,
- cc.code AS code,
- 0 AS duration_time,
- NULL AS section_type,
- NULL AS live_start_time,
- NULL AS live_end_time,
- NULL AS live_url,
- NULL AS recording_url,
- NULL AS exam_type,
- NULL AS free_exam_id,
- NULL as free_exam_name
- FROM
- course_menu m
- LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
- WHERE
- m.course_id = #{courseId}
- AND m.type = 2 and cc.`status`!=-1
- UNION
- SELECT
- m.*,
- cs.`name` AS menu_name,
- cs.publish_status AS publish_status,
- cs.code AS code,
- cs.duration_time AS duration_time,
- cs.section_type AS section_type,
- cs.live_start_time AS live_start_time,
- cs.live_end_time AS live_end_time,
- cs.live_url AS live_url,
- cs.recording_url AS recording_url,
- NULL AS exam_type,
- NULL AS free_exam_id,
- NULL as free_exam_name
- FROM
- course_menu m
- LEFT JOIN course_section cs ON m.menu_id = cs.section_id
- WHERE
- m.course_id = #{courseId}
- AND m.type = 3 and cs.`status`!=-1 )un
- WHERE 1=1
- <if test="type != null and type != ''">
- AND un.type = #{type}
- </if>
- ORDER BY un.sort asc
- </select>
- <select id="menuList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserMenuVo">
- SELECT
- m.*,
- #{gradeId} as grade_id,
- CASE
- WHEN m.type = 1 THEN
- cm.module_name
- WHEN m.type = 2 THEN
- cc.`name`
- WHEN m.type = 3 THEN
- cs.`name`
- END menu_name,
- CASE
- WHEN m.type = 1 THEN
- 0
- WHEN m.type = 2 THEN
- 0
- WHEN m.type = 3 THEN
- cs.duration_time
- END duration_time,
- cs.section_type,
- cs.live_start_time,
- cs.live_end_time,
- cs.live_url,
- CASE
- WHEN m.type = 1 THEN
- ''
- WHEN m.type = 2 THEN
- ''
- WHEN m.type = 3 THEN
- cs.recording_url
- END recording_url,
- CASE
- WHEN m.type = 1 THEN
- ''
- WHEN m.type = 2 THEN
- ''
- WHEN m.type = 3 THEN
- (SELECT teacher_name from teacher where teacher_id = cs.teacher_id)
- END teacher_name
- FROM
- course_menu m
- LEFT JOIN course_module cm ON m.menu_id = cm.module_id
- AND m.type = 1 and cm.status=1
- LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
- AND m.type = 2 and cc.status=1
- LEFT JOIN course_section cs ON m.menu_id = cs.section_id
- AND m.type = 3 and cs.status=1
- WHERE
- m.course_id = #{courseId}
- ORDER BY m.sort
- </select>
- <select id="getGoodsMenuList" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserMenuVo">
- SELECT
- gc.goods_id,
- m.*,
- #{gradeId} as grade_id,
- CASE
- WHEN m.type = 1 THEN
- cm.module_name
- WHEN m.type = 2 THEN
- cc.`name`
- WHEN m.type = 3 THEN
- cs.`name`
- END menu_name,
- CASE
- WHEN m.type = 1 THEN
- 0
- WHEN m.type = 2 THEN
- 0
- WHEN m.type = 3 THEN
- cs.duration_time
- END duration_time,
- cs.section_type,
- cs.live_start_time,
- cs.live_end_time,
- cs.live_url,
- CASE
- WHEN m.type = 1 THEN
- ''
- WHEN m.type = 2 THEN
- ''
- WHEN m.type = 3 THEN
- cs.recording_url
- END recording_url,
- CASE
- WHEN m.type = 1 THEN
- ''
- WHEN m.type = 2 THEN
- ''
- WHEN m.type = 3 THEN
- (SELECT teacher_name from teacher where teacher_id = cs.teacher_id)
- END teacher_name
- FROM
- goods_course gc
- INNER JOIN course_menu m ON gc.course_id = m.course_id
- LEFT JOIN course_module cm ON m.menu_id = cm.module_id
- AND m.type = 1 and cm.status=1
- LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
- AND m.type = 2 and cc.status=1
- LEFT JOIN course_section cs ON m.menu_id = cs.section_id
- AND m.type = 3 and cs.status=1
- WHERE
- gc.goods_id = #{goodsId}
- ORDER BY m.sort
- </select>
- <select id="rebuildCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= 0
- and up.chapter_id=0
- and up.course_id=#{courseId}
- and up.section_id=#{sectionId}
- AND ups.period_status =1
- and (ups.`status` = 0 or ups.`status` = 3)
- </select>
- <delete id="deleteByIdTenant" parameterType="map">
- delete from course_menu where course_id = #{newCourseId} and tenant_id = #{newTenantId}
- </delete>
- <select id="rebuildSectionCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= #{moduleId}
- and up.chapter_id= #{chapterId}
- and up.course_id=#{courseId}
- and up.section_id=#{sectionId}
- AND ups.period_status =1
- and (ups.`status` = 0 or ups.`status` = 3)
- </select>
- <select id="auditCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= 0
- and up.chapter_id=0
- and up.course_id=#{courseId}
- and up.section_id=#{sectionId}
- AND ups.period_status =1
- and ups.`status` = 1
- </select>
- <select id="rebuildChapterCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= 0
- and up.course_id=#{courseId}
- and up.chapter_id=#{chapterId}
- AND ups.period_status =1
- and (ups.`status` = 0 or ups.`status` = 3)
- </select>
- <select id="rebuildModuleCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= #{moduleId}
- AND up.course_id=#{courseId}
- AND ups.period_status =1
- and (ups.`status` = 0 or ups.`status` = 3)
- </select>
- <select id="learningCheck" parameterType="map" resultType="Integer">
- SELECT
- COUNT(up.id)
- FROM
- user_period up
- LEFT JOIN user_period_status ups ON up.id = ups.period_id
- WHERE
- up.grade_id =#{gradeId}
- AND up.user_id = #{userId}
- AND up.module_id= 0
- and up.chapter_id=0
- and up.section_id=#{sectionId}
- and up.course_id=#{courseId}
- AND ups.period_status =1
- and ups.record_end_time is not null
- </select>
- <select id="getStudyDuration" parameterType="map" resultType="long">
- SELECT
- IFNULL(MAX(usr.video_current_time),0) as study_duration
- FROM
- user_study_record usr
- WHERE
- usr.grade_id =#{gradeId}
- AND usr.user_id = #{userId}
- AND usr.module_id= 0
- and usr.chapter_id=0
- and usr.section_id=#{sectionId}
- and usr.course_id=#{courseId}
- AND usr.current_status =1
- </select>
- </mapper>
|