nxdt-system/bonus-modules/bonus-exam/src/main/resources/mapper/exam/CoursewareLibraryMapper.xml

158 lines
7.2 KiB
XML

<?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.bonus.exam.mapper.CoursewareLibraryMapper">
<!--添加课件库-文件目录-->
<insert id="addFolder">
INSERT INTO edu_courseware
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="coursewareName != null and coursewareName != ''">courseware_name,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="createUserName != null and createUserName!=''">create_user_name,</if>
create_time,
update_time,
file_type,
parent_id,
is_active,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="coursewareName != null and coursewareName != ''">#{coursewareName},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="createUserName != null and createUserName!=''">#{createUserName},</if>
#{createTime},
#{updateTime},
'1',
#{parentId},
'1'
</trim>
</insert>
<!--批量添加课件库-->
<insert id="batchAddCourseware">
INSERT INTO edu_courseware(courseware_id,courseware_name,courseware_size,study_time,create_user_id,create_user_name,
create_time,update_time,file_type,parent_id,is_active,marl,file_path,suffix) VALUES
<foreach collection="list" separator="," item="item">
(
null,#{item.coursewareName},#{item.coursewareSize},#{item.studyTime},#{item.createUserId},#{item.createUserName},
#{item.createTime},#{item.updateTime},#{item.fileType},#{item.parentId},'1',#{item.marl},#{item.filePath},#{item.suffix}
)
</foreach>
</insert>
<!--重命名课件库-课件库-文件目录/文件-1.重命名 2.备注 3.删除 4.移动-->
<update id="operFolderOrFile">
<if test="operType == 1">
UPDATE edu_courseware SET courseware_name = #{coursewareName},update_time = #{updateTime} WHERE courseware_id = #{coursewareId}
</if>
<if test="operType == 2">
UPDATE edu_courseware SET marl = #{marl},update_time = #{updateTime} WHERE courseware_id = #{coursewareId}
</if>
<if test="operType == 3">
UPDATE edu_courseware SET is_active = '0' WHERE courseware_id IN (
<foreach collection="delData" item="id" index="index" separator=",">
#{id}
</foreach>
)
</if>
<if test="operType == 4">
UPDATE edu_courseware SET parent_id = #{parentId} WHERE courseware_id = #{coursewareId}
</if>
</update>
<!--判断同一层级文件目录是否存在-->
<select id="isExistFolder" resultType="java.lang.Integer">
<if test="coursewareId == null">
SELECT COUNT(*) FROM edu_courseware WHERE courseware_name = #{coursewareName} AND parent_id = #{parentId} AND is_active = '1'
</if>
<if test="coursewareId != null">
SELECT COUNT(*) FROM edu_courseware WHERE courseware_id != #{coursewareId} AND courseware_name = #{coursewareName} AND parent_id = #{parentId} AND is_active = '1'
</if>
</select>
<!--课件库-treeTable列表-->
<select id="getCoursewareTreeTable" resultType="com.bonus.common.exam.vo.CoursewareVo">
SELECT courseware_id AS coursewareId,
courseware_name AS coursewareName,
IFNULL(suffix,'.zip') as suffix,
IFNULL(courseware_size,0) AS coursewareSize,
IFNULL(study_time,0) AS studyTime,
create_user_name AS createUserName,
update_time AS updateTime,
file_type AS fileType,
parent_id AS parentId,
file_path AS filePath,
IFNULL(marl,'') AS marl
FROM edu_courseware
WHERE is_active = '1'
ORDER BY update_time
</select>
<!--根据文件ID获取下面的所有子集-->
<select id="getChilds" resultType="com.bonus.common.exam.vo.CoursewareVo">
SELECT courseware_id AS coursewareId,
parent_id AS parentId,
file_type AS fileType,
file_path AS filePath,
courseware_name AS coursewareName,
suffix
FROM (
SELECT courseware_id,parent_id,file_type,file_path,courseware_name,suffix
FROM edu_courseware
WHERE is_active = '1'
ORDER BY parent_id, courseware_id
) org_query,
(SELECT @courseware_id := #{coursewareId}) initialisation
WHERE FIND_IN_SET(parent_id, @courseware_id) > 0 AND @courseware_id := CONCAT(@courseware_id, ',', courseware_id)
UNION ALL
SELECT courseware_id AS coursewareId,
parent_id AS parentId,
file_type AS fileType,
file_path AS filePath,
courseware_name AS coursewareName,
suffix
FROM edu_courseware
WHERE courseware_id = #{coursewareId} AND is_active = '1'
</select>
<!--获取文件详情-->
<select id="getFilePath" resultType="com.bonus.common.exam.vo.CoursewareVo">
SELECT courseware_name AS coursewareName,
file_path AS filePath,suffix
FROM edu_courseware WHERE courseware_id = #{coursewareId}
</select>
<!--获取节点的所有的父层级-->
<select id="getTempFilePaths" resultType="java.lang.String">
SELECT ece.courseware_name AS coursewareName FROM (
SELECT t2.courseware_id
FROM ( SELECT @r AS _id, (SELECT @r := parent_id FROM edu_courseware WHERE courseware_id = _id) AS parent_id,
@l := @l + 1 AS lvl FROM (SELECT @r := #{coursewareId}, @l := 0) vars, edu_courseware WHERE @r != 0) t1
JOIN edu_courseware t2 ON t1._id = t2.courseware_id
ORDER BY t1.lvl DESC
) a
LEFT JOIN edu_courseware ece ON a.courseware_id = ece.courseware_id
</select>
<!--题库tree-->
<select id="getCoursewareLibraryTree" resultType="com.bonus.common.exam.vo.CoursewareLibraryTreeVo">
SELECT courseware_id AS coursewareId,
courseware_name AS coursewareName,
parent_id AS parentId
FROM edu_courseware
WHERE file_type = '1' AND is_active = '1'
ORDER BY update_time
</select>
<!--查询库中是否已经存在选项图片-->
<select id="isHasQuestionsPicture" resultType="java.lang.Integer">
SELECT COUNT(*) FROM edu_questions_picture WHERE parent_id = #{answerId} AND picture_type = '2'
</select>
<select id="getSelectFileToDownload" resultType="com.bonus.common.exam.vo.CoursewareVo">
SELECT
courseware_id AS coursewareId,
parent_id AS parentId,
file_type AS fileType,
file_path AS filePath,
courseware_name AS coursewareName,
suffix
FROM edu_courseware
WHERE courseware_id in
<foreach collection="arr" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>