package com.qxueyou.scc.controller;
|
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
import com.qxueyou.scc.admin.classes.model.ClsClassReSubject;
|
import com.qxueyou.scc.admin.classes.service.IClassLectureService;
|
import com.qxueyou.scc.teach.subject.model.Subject;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.qxueyou.scc.admin.progress.model.Progress;
|
import com.qxueyou.scc.admin.progress.service.IProgressService;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.util.ClientUtils;
|
import com.qxueyou.scc.base.util.CollectionUtils;
|
import com.qxueyou.scc.base.util.QBeanUtils;
|
import com.qxueyou.scc.teach.res.model.Res;
|
import com.qxueyou.scc.teach.res.model.ResLib;
|
import com.qxueyou.scc.teach.res.service.IResService;
|
import com.qxueyou.scc.teach.subject.model.SubjectChapter;
|
import com.qxueyou.scc.teach.subject.model.SubjectLecture;
|
import com.qxueyou.scc.teach.subject.service.ILectureService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
|
/**
|
* 课件控制器
|
*
|
* @author chenjunliang
|
*
|
*/
|
@Api(tags = "课件管理-管理员端")
|
@RestController
|
@RequestMapping(value = "teach/courseware")
|
public class CoursewareController {
|
|
@Autowired
|
ILectureService lectureService;
|
|
@Autowired
|
IClassLectureService classLectureService;
|
|
@Autowired
|
IResService resService;
|
|
@Autowired
|
IProgressService progressService;
|
|
/**
|
* 加载课件tree
|
*
|
* @param parentId
|
* 父节点id
|
*/
|
@GetMapping(value = "categoryTree")
|
public Result categoryTree(String subjectId, String parentId) {
|
|
List<SubjectChapter> chapterLst = lectureService.doGetListChapter(subjectId, parentId);
|
|
return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst,
|
CollectionUtils.newStringMap("name", "name", "chapterId", "id")));
|
}
|
|
/**
|
* 获取课件列表
|
*
|
* @param chapterId
|
* 章节id
|
* @param type
|
* 课件类型
|
* @param keyword
|
* 搜索关键字
|
* @param limit
|
* 每页显示几条
|
* @param pageNum
|
* 页码
|
* @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
|
*/
|
@GetMapping(value = "coursewareList")
|
public Result coursewareList(String chapterId, String type, String keyword, Integer limit, Integer pageNum) {
|
|
List<SubjectLecture> lectures = lectureService.listLecture(chapterId, keyword, limit, pageNum, type);
|
|
int lectureCount = lectureService.listLectureCount(chapterId, keyword, type);
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("coursewareLst",
|
QBeanUtils.listBean2ListMap(lectures,
|
CollectionUtils.newStringMap("name", "name", "lectureId", "id", "lectureType", "type",
|
"chapterId", "chapterId", "status", "status", "updateTime", "updateTime")),
|
"count", lectureCount));
|
|
}
|
|
/**
|
* 查看课件
|
*
|
* @param id
|
* 课件id
|
* @param attribute
|
* 扩展属性 video:"mp4:HD","m3u8:SD" 可不用传 audio:可不用传 doc:可不用传
|
*/
|
@ApiOperation(value = "查看课件", notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "id", value = "课件id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "attribute", value = "扩展属性 video:\"mp4:HD\",\"m3u8:SD\" 可不用传 audio:可不用传 doc:可不用传", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "showCourseware")
|
public Result showCourseware(String id, String attribute) {
|
|
Result result = lectureService.readLectureAccessPath(id, null);
|
|
Progress progress = progressService.query(Progress.PROGRESS_TYPE_LECTURE, id, ClientUtils.getUserId());
|
|
return new Result(true, "true",
|
CollectionUtils.newObjectMap("name", result.getDataT("name"), "fullPath", result.getDataT("path"), "id", id, "size", result.getDataT("size"),
|
"percent", progress == null ? 0 : String.valueOf(progress.getProgressPercent())));
|
}
|
|
/**
|
* 删除课件
|
*
|
* @param id
|
* 课件ids
|
*/
|
@GetMapping(value = "deleteCourseware")
|
public Result deleteCourseware(String id) {
|
|
Result result = lectureService.deleteLecture(id.split(","));
|
// lectureService.deleteLectureLoad(id.split(","));
|
return result;
|
|
}
|
|
/**
|
* 课件的复制
|
*
|
* @param id
|
* 课件id
|
* @param type
|
* 课件类型
|
* @param chapterId
|
* 章Id
|
* @param sectionId
|
* 节id
|
* @param smallSectionId
|
* 小节id
|
* @param name
|
* 课件名称
|
*/
|
@GetMapping(value = "copy")
|
public Result copy(String id, String type, String subjectId, String chapterId, String name) {
|
return lectureService.doCopyLecture(id, chapterId, name);
|
}
|
|
/**
|
* 课件的移动
|
*
|
* @param id
|
* 课件id
|
* @param type
|
* 课件类型
|
* @param chapterId
|
* 章Id
|
* @param sectionId
|
* 节id
|
* @param smallSectionId
|
* 小节id
|
*/
|
@GetMapping(value = "move")
|
public Result moveCourseware(String id, String type, String subjectId, String chapterId, String name) {
|
return lectureService.doMoveLecture(id, chapterId, name);
|
}
|
|
/**
|
* 课件管理 新增下级,同级
|
*
|
* @param type
|
* (add:新增,edit :编辑)
|
* @param chapterId
|
* 章节id
|
* @param subjectId
|
* 课程id
|
* @param name
|
* 名称
|
* @param childFlag
|
* 是否操作下级
|
*
|
*/
|
@PostMapping(value = "addOrUpdateChapter")
|
public Result addOrUpdateChapter(String type, String name, String chapterId, String subjectId, boolean childFlag) {
|
|
SubjectChapter chapter = lectureService.readChapter(chapterId);
|
String parentChapterId = childFlag ? chapterId : chapter.getParentChapterId();
|
|
if ("add".equals(type)) {
|
return lectureService.addChapter(subjectId, parentChapterId, name);
|
} else {
|
return lectureService.updateChapter(chapterId, name);
|
}
|
|
}
|
|
/**
|
* 课件管理 目录删除
|
*
|
* @param chapterId
|
* 目录id
|
*/
|
@GetMapping(value = "deleteChapter")
|
public Result deleteChapter(String chapterId) {
|
return lectureService.deleteChapter(chapterId.split(","));
|
}
|
|
/**
|
* 添加/更新(视频,讲义,音频)
|
*
|
* @param name
|
* 名称
|
* @param coverUrl
|
* 封面Url
|
* @param remark:
|
* <p>
|
* 视频啊啊啊
|
* </p>
|
* 介绍
|
*
|
* @param id
|
* 课件id
|
* @param sectionId
|
* 小节Id
|
* @param type
|
* @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
|
*/
|
@PostMapping(value = "addOrUpdate")
|
public Result addOrUpdate(String id, String remark, String name, String coverUrl, String type, String fileId,
|
String sectionId) {
|
|
if (StringUtils.isEmpty(id)) {
|
|
Result resResult = resService.add(
|
resService.doGetRootDir(ResLib.OWNNER_TYPE_USER, ClientUtils.getUserId()).getDirId(), fileId, name,
|
remark, type, coverUrl);
|
|
return lectureService.addLecture(sectionId, resResult.getDataT("resId"));
|
|
} else {
|
|
SubjectLecture lecture = lectureService.readLecture(id);
|
|
resService.update(lecture.getResItemId(), name, remark, coverUrl);
|
return lectureService.updateLecture(lecture.getLectureId(), lecture.getResItemId());
|
}
|
}
|
|
/**
|
* 编辑 获取内容
|
*
|
* @param id
|
* 课件id
|
*/
|
@GetMapping(value = "getCoursewareDetail")
|
public Result getCoursewareDetail(String id) {
|
|
SubjectLecture lecture = lectureService.readLecture(id);
|
|
Res res = resService.read(lecture.getResItemId());
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("coursewareName", lecture.getName(), "coverUrl", res.getCoverPageUrl(),
|
"remark", res.getRemark(), "fileId", null, "name", lecture.getName(), "id",
|
lecture.getLectureId()));
|
}
|
|
/**
|
* 课件获取资源列表
|
*
|
* @param dirId
|
* 目录Id
|
* @param limit
|
* 每页显示几条
|
* @param pageNum
|
* 页码
|
* @return 状态说明(0,视频。1,音频。2,文档。3,练习。)
|
*/
|
@GetMapping(value = "getResLst")
|
public Result getResLst(String dirId, Integer limit, Integer pageNum, String keyword) {
|
|
List<Res> resLst = resService.listMyRes(keyword, limit, pageNum, "");
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("resCount", resService.listMyResCount(keyword, ""), "resLst",
|
|
QBeanUtils.listBean2ListMap(resLst,
|
CollectionUtils.newStringMap("resId", "resId", "name", "resName", "type", "type"))));
|
}
|
|
/**
|
* 课件从资源选择后保存
|
*
|
* @param resId
|
* 资源文件id
|
* @param sectionId
|
* 小节id
|
*
|
*/
|
@GetMapping(value = "saveCourseware4Res")
|
public Result saveCourseware4Res(String resId, String sectionId) {
|
|
int successCount = 0;
|
Result result = new Result(true);
|
|
for (String resId_ : resId.split(",")) {
|
result = lectureService.addLecture(sectionId, resId_);
|
successCount = result.isSuccess() ? 1 : 0;
|
}
|
return new Result(true, null, successCount);
|
}
|
|
/**
|
* 获取练习成绩列表
|
*
|
* @param subjectId
|
* 课程id
|
* @param exerciseId
|
* 练习id
|
* @param pageSize
|
* 每页显示几条
|
* @param pageNum
|
* 页码
|
*
|
*/
|
@GetMapping(value = "lstExerciseScore")
|
public Result lstExerciseScore(String subjectId, String exerciseId, Integer pageSize, Integer pageNum) {
|
Map<String, Object> lstExerciseGradeOne = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
|
"李刚1", "className", "catti", "mockTime", new Date(), "status", 1, "score", 60, // status 0 表示未提交,1是已提交
|
"passingFlag", 1);// passingFlag 1,true,0 false
|
Map<String, Object> lstExerciseGradeTwo = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
|
"李刚2", "className", "catti", "mockTime", new Date(), "status", 0, "score", 70, "passingFlag", 0);
|
Map<String, Object> lstExerciseGradeThree = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName",
|
"李刚3", "className", "catti", "mockTime", new Date(), "status", 1, "score", 80, "passingFlag", 1);
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("scoreLst",
|
CollectionUtils.newList(lstExerciseGradeOne, lstExerciseGradeTwo, lstExerciseGradeThree),
|
"scoreCount", 3));
|
}
|
|
/**
|
* 练习成绩的导出
|
*
|
* @param subjectId
|
* 课程id
|
* @param exerciseId练习id
|
*/
|
@GetMapping(value = "exportScore")
|
public Result exportScore(String subjectId, String exerciseId) {
|
return new Result(true, "success");
|
}
|
|
}
|