package com.qxueyou.scc.controller; import java.util.Date; import java.util.List; import java.util.Map; import com.qxueyou.scc.admin.classes.service.IClassLectureService; 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 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 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) { return lectureService.deleteLecture(id.split(",")); } /** * ¿Î¼þµÄ¸´ÖÆ * * @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: *

* ÊÓÆµ°¡°¡°¡ *

* ½éÉÜ * * @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 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 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 lstExerciseGradeTwo = CollectionUtils.newObjectMap("studentNumber", 201342, "studentName", "Àî¸Õ2", "className", "catti", "mockTime", new Date(), "status", 0, "score", 70, "passingFlag", 0); Map 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"); } }