| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <?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.zd.exam.mapper.ElCourseChapterMapper">
- <resultMap type="com.zd.exam.domain.ElCourseChapter" id="ElCourseChapterResult">
- <result property="id" column="id"/>
- <result property="userId" column="user_id"/>
- <result property="createBy" column="create_by"/>
- <result property="updateBy" column="update_by"/>
- <result property="deptId" column="dept_id"/>
- <result property="deptName" column="dept_name"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="remark" column="remark"/>
- <result property="courseId" column="course_id"/>
- <result property="title" column="title"/>
- <result property="parentId" column="parent_id"/>
- <result property="position" column="position"/>
- <result property="resourcesId" column="resources_id"/>
- <result property="chapterData" column="chapter_data"/>
- <result property="description" column="description"/>
- <result property="free" column="free"/>
- <result property="type" column="type"/>
- <result property="allowdownload" column="allowdownload"/>
- <result property="duration" column="duration"/>
- <result property="isAssess" column="is_assess"/>
- <result property="assessName" column="assess_name"/>
- </resultMap>
- <sql id="selectElCourseChapterVo">
- select id,
- user_id,
- create_by,
- update_by,
- dept_id,
- dept_name,
- create_time,
- update_time,
- remark,
- course_id,
- title,
- parent_id,
- position,
- resources_id,
- chapter_data,
- description,
- free,
- type,
- allowdownload,
- duration,
- is_assess,
- assess_name
- from el_course_chapter
- </sql>
- <sql id="selectElCourseChapterListVo">
- select t.id,
- t.user_id,
- t.create_by,
- t.update_by,
- t.dept_id,
- t.dept_name,
- t.create_time,
- t.update_time,
- t.remark,
- t.course_id,
- t.title,
- t.parent_id,
- t.position,
- t.resources_id,
- t.chapter_data,
- t.description,
- t.free,
- ifnull(r.type, t.type) type,
- t.allowdownload,
- t.duration,
- r.postfix,
- t.is_assess,
- t.assess_name
- from el_course_chapter as t
- left join el_resources r on t.resources_id = r.id
- </sql>
- <select id="selectElCourseChapterList" parameterType="com.zd.exam.domain.ElCourseChapter"
- resultMap="ElCourseChapterResult">
- <include refid="selectElCourseChapterListVo"/>
- <where>
- <if test="userId != null ">and t.user_id = #{userId}</if>
- <if test="deptId != null ">and t.dept_id = #{deptId}</if>
- <if test="deptName != null and deptName != ''">and t.dept_name like concat('%', #{deptName}, '%')</if>
- <if test="courseId != null ">and t.course_id = #{courseId}</if>
- <if test="title != null and title != ''">and t.title = #{title}</if>
- <if test="parentId != null ">and t.parent_id = #{parentId}</if>
- <if test="position != null ">and t.position = #{position}</if>
- <if test="resourcesId != null ">and t.resources_id = #{resourcesId}</if>
- <if test="chapterData != null and chapterData != ''">and t.chapter_data = #{chapterData}</if>
- <if test="description != null and description != ''">and t.description = #{description}</if>
- <if test="free != null ">and t.free = #{free}</if>
- <if test="type != null ">and r.type = #{type}</if>
- <if test="allowdownload != null ">and t.allowdownload = #{allowdownload}</if>
- <if test="duration != null ">and t.duration = #{duration}</if>
- </where>
- </select>
- <select id="selectElCourseChapterById" resultMap="ElCourseChapterResult">
- <include refid="selectElCourseChapterVo"/>
- where id = #{id}
- </select>
- <select id="selectChapterLearnByCourseId" resultType="com.zd.exam.domain.vo.ChapterLearnVo">
- select
- c.id as courseId,
- c.title as courseTitle,
- cc.id as chapterId,
- cc.title as chapterTitle,
- cc.type as chapterType,
- cl.join_user_id as joinUserId,
- ifnull(cl.status, 2) as learnStatus
- from el_course c left join el_course_chapter cc on c.id = cc.course_id
- left join el_chapter_learn_record cl on c.id = cl.course_id and cc.id = cl.chapter_id
- where
- c.id = #{courseId} and (cl.join_user_id = #{joinUserId} or cl.join_user_id is null)
- </select>
- <select id="selectUserCourseChapterList" resultType="com.zd.exam.domain.ElCourseChapter">
- select t.id,
- t.user_id,
- t.create_by,
- t.update_by,
- t.dept_id,
- t.dept_name,
- t.create_time,
- t.update_time,
- t.remark,
- t.course_id,
- t.title,
- t.parent_id,
- t.position,
- t.resources_id,
- t.chapter_data,
- t.description,
- t.free,
- ifnull(r.type, t.type) type,
- t.allowdownload,
- t.duration,
- t.is_assess,
- (select count(1) from el_paper p where p.course_chapter_id = t.id and p.join_user_id = cl.join_user_id) as hasAssess,
- t.assess_name,
- r.postfix,
- ifnull(cl.status, 2) as learnStatus,
- case when t.is_assess = 0 then 1
- when (select count(1) from el_paper p where p.course_chapter_id = t.id and p.join_user_id = cl.join_user_id and p.total_score = p.user_score) > 0
- then 1
- else 0 end as assessStatus
- from el_course_chapter as t
- left join el_resources r on t.resources_id = r.id
- left join el_chapter_learn_record cl on t.id = cl.chapter_id and cl.join_user_id = #{userId}
- where
- t.course_id = #{courseId}
- </select>
- <select id="selectLearnDurationsByUserId" resultType="java.lang.Long">
- select sum(ifnull(duration, 0)) from el_chapter_learn_record where course_id = #{courseId} and join_user_id = #{userId} and status = 1
- </select>
- <select id="selectCourseTitleByChapterId" resultType="java.lang.String">
- select
- c.title as title
- from el_chapter_learn_record cl left join el_course c on cl.course_id = c.id
- where cl.id = #{recordId}
- </select>
- <select id="selectChapterDurationsByUserId" resultType="java.lang.Long">
- select ifnull(sum(duration), 0) from el_chapter_learn_record where chapter_id = #{chapterId} and join_user_id = #{userId} and status = 1
- </select>
- <insert id="insertElCourseChapter" parameterType="com.zd.exam.domain.ElCourseChapter" useGeneratedKeys="true"
- keyProperty="id">
- insert into el_course_chapter
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">user_id,</if>
- <if test="createBy != null">create_by,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="deptId != null">dept_id,</if>
- <if test="deptName != null">dept_name,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- <if test="courseId != null">course_id,</if>
- <if test="title != null and title != ''">title,</if>
- <if test="parentId != null">parent_id,</if>
- <if test="position != null">position,</if>
- <if test="resourcesId != null">resources_id,</if>
- <if test="chapterData != null">chapter_data,</if>
- <if test="description != null and description != ''">description,</if>
- <if test="free != null">free,</if>
- <if test="type != null">type,</if>
- <if test="allowdownload != null">allowdownload,</if>
- <if test="duration != null">duration,</if>
- <if test="isAssess != null">is_assess,</if>
- <if test="assessName != null">assess_name,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">#{userId},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="deptId != null">#{deptId},</if>
- <if test="deptName != null">#{deptName},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- <if test="courseId != null">#{courseId},</if>
- <if test="title != null and title != ''">#{title},</if>
- <if test="parentId != null">#{parentId},</if>
- <if test="position != null">#{position},</if>
- <if test="resourcesId != null">#{resourcesId},</if>
- <if test="chapterData != null">#{chapterData},</if>
- <if test="description != null and description != ''">#{description},</if>
- <if test="free != null">#{free},</if>
- <if test="type != null">#{type},</if>
- <if test="allowdownload != null">#{allowdownload},</if>
- <if test="duration != null">#{duration},</if>
- <if test="isAssess != null">#{isAssess},</if>
- <if test="assessName != null">#{assessName},</if>
- </trim>
- </insert>
- <update id="updateElCourseChapter" parameterType="com.zd.exam.domain.ElCourseChapter">
- update el_course_chapter
- <trim prefix="SET" suffixOverrides=",">
- <if test="userId != null">user_id = #{userId},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="deptId != null">dept_id = #{deptId},</if>
- <if test="deptName != null">dept_name = #{deptName},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="courseId != null">course_id = #{courseId},</if>
- <if test="title != null and title != ''">title = #{title},</if>
- <if test="parentId != null">parent_id = #{parentId},</if>
- <if test="position != null">position = #{position},</if>
- <if test="resourcesId != null">resources_id = #{resourcesId},</if>
- <if test="chapterData != null">chapter_data = #{chapterData},</if>
- <if test="description != null and description != ''">description = #{description},</if>
- <if test="free != null">free = #{free},</if>
- <if test="type != null">type = #{type},</if>
- <if test="allowdownload != null">allowdownload = #{allowdownload},</if>
- <if test="duration != null">duration = #{duration},</if>
- <if test="isAssess != null">is_assess = #{isAssess},</if>
- <if test="assessName != null">assess_name = #{assessName},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteElCourseChapterById" >
- delete
- from el_course_chapter
- where id = #{id}
- </delete>
- <delete id="deleteElCourseChapterByIds">
- delete from el_course_chapter where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|