package com.qxueyou.scc.stucontroller;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import com.qxueyou.scc.user.model.User;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.web.bind.annotation.*;
|
|
import com.alibaba.druid.util.StringUtils;
|
import com.qxueyou.scc.admin.classes.model.ClsSubjectLecture;
|
import com.qxueyou.scc.admin.classes.service.IClassLectureService;
|
import com.qxueyou.scc.admin.progress.dao.ProgressDAO;
|
import com.qxueyou.scc.admin.progress.model.view.SubjectProgressTreeV;
|
import com.qxueyou.scc.base.model.Pager;
|
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.CommonUtils;
|
import com.qxueyou.scc.base.util.QBeanUtils;
|
import com.qxueyou.scc.evaluate.service.IEvaluateService;
|
import com.qxueyou.scc.operation.topic.service.ITopicService;
|
import com.qxueyou.scc.teach.res.service.IResAudioService;
|
import com.qxueyou.scc.teach.subject.model.view.LectureAudioV;
|
import com.qxueyou.scc.teach.subject.model.view.MyLectureV;
|
import com.qxueyou.scc.teach.subject.model.view.MySubjectV;
|
import com.qxueyou.scc.teach.subject.service.ILectureService;
|
import com.qxueyou.scc.teach.subject.service.ISubjectService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
/**
|
* ѧϰ¶Ë ¿Î³Ìǰ¶Ë¿ØÖÆÆ÷
|
*
|
* @author chenjunliang
|
*
|
*/
|
@Api(tags= "¿Î³Ì¹ÜÀí-ѧԱ¶Ë")
|
@RestController
|
@CrossOrigin(origins="*",maxAge=3600)
|
@RequestMapping(value = "stu/subject")
|
public class StuSubjectController {
|
|
@Autowired
|
ISubjectService subjectService;
|
|
@Autowired
|
ILectureService lectureService;
|
|
@Autowired
|
IClassLectureService clsLectureService;
|
|
@Autowired
|
IResAudioService audioService;
|
|
@Autowired
|
ProgressDAO progressDao;
|
|
@Autowired
|
ITopicService topicService;
|
|
@Autowired
|
IEvaluateService evaluateService;
|
|
//--------------------------------------------------------------app¶Ë½Ó¿Ú---------------------------------------------------------------------------------------------------
|
/**
|
* ѧϰ¶Ë»ñÈ¡ ËùÓпμþ
|
*
|
* @param classId
|
* @return ״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
|
*/
|
@ApiOperation(value = "»ñÈ¡°à¼¶ËùÓпμþ-ѧϰ¶Ë", notes = "״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "sort", value = "ÅÅÐò·½Ê½£¨desc´Ó´óµ½Ð¡,asc´ÓСµ½´ó£©", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/getCoursewareLstByClassId")
|
public Result appCoursewareLst(String classId, @RequestParam(defaultValue="desc")String sort, Pager pager) {
|
System.out.println(classId);
|
return clsLectureService.listSubjectLecture(CommonUtils.getClassId(classId), sort, pager);
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡¿Î³ÌѧÄêÁбí")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/termList")
|
public Result termList(String classId) {
|
classId = CommonUtils.getClassId(classId);
|
if(StringUtils.isEmpty(classId)) {
|
return new Result(false, "°à¼¶id²»ÄÜΪ¿Õ");
|
}
|
//¿Î³Ì
|
List<Map<String, Object>> lstSubject = subjectService.clsSubjectlist(classId, null, null);
|
//×é×°µÄѧÆÚºÍ¿Î³Ì
|
List<Map<String, Object>> lstTerm = subjectService.termSubjectList(classId, lstSubject);
|
|
return new Result(true, "success",CollectionUtils.newObjectMap("termList", lstTerm, "allSubject", lstSubject));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ÎҵĿγ̰´Ñ§ÆÚ·ÖÀà")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/myTermSubjectList")
|
public Result myTermSubjectList(String classId) {
|
classId = CommonUtils.getClassId(classId);
|
System.out.println("vvvvvvvvv"+classId);
|
if(StringUtils.isEmpty(classId)) {
|
return new Result(false, "°à¼¶id²»ÄÜΪ¿Õ");
|
}
|
return new Result(true, "success",subjectService.myTermSubjectList(classId));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ÎҵĿγ̰´Ê±¼äÅÅÐò")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/mySubjectList")
|
public Result mySubjectList(String classId, Pager pager ) {
|
// System.out.println("0.0.0.0"+classId);
|
classId = CommonUtils.getClassId(classId);
|
long count = subjectService.myClsSubjectCount(classId);
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("count", count, "listData", subjectService.mySubjectList(classId, pager)));
|
}
|
|
/**
|
* ÎҵĿγÌÏêÇé
|
*
|
* @param subjectId
|
* @param classId
|
* @return
|
*/
|
@ApiOperation(value = "ÎҵĿγÌÏêÇé")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "subjectId", value = "¿Î³Ìid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/mySubjectInfo")
|
public Result mySubjectInfo(String subjectId, String classId) {
|
classId = CommonUtils.getClassId(classId);
|
if(StringUtils.isEmpty(classId)) {
|
return new Result(false, "°à¼¶id²»ÄÜΪ¿Õ");
|
}
|
if(StringUtils.isEmpty(subjectId)) {
|
return new Result(false, "¿Î³Ìid²»ÄÜΪ¿Õ");
|
}
|
return new Result(true, "success", subjectService.mySubjectInfo(subjectId, classId));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "Îҵİ༶ÐÅÏ¢")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/myClassInfo")
|
public Result myClassInfo(String classId) {
|
classId = ClientUtils.getClassId();
|
if(StringUtils.isEmpty(classId)) {
|
return new Result(false, "°à¼¶id²»ÄÜΪ¿Õ");
|
}
|
return new Result(true, "success",subjectService.myClassInfo(classId));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "schoolYear", value = "ѧÄê", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "term", value = "ѧÆÚ", required = true, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "/app/subjectList")
|
public Result subjectList(String classId, Integer schoolYear, Integer term) {
|
return new Result(true, "success",subjectService.clsSubjectlist(CommonUtils.getClassId(classId), schoolYear, term));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡¿Î³ÌÏ¿μþ£¬°´´´½¨Ê±¼äÅÅÐò")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "subjectId", value = "¿Î³Ìid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "sort", value = "ÅÅÐò·½Ê½£¨desc´Ó´óµ½Ð¡,asc´ÓСµ½´ó£©", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "/app/listLectureBySubject")
|
public Result listLectureBySubject(String subjectId, String classId, @RequestParam(defaultValue="desc")String sort, Pager pager) {
|
return new Result(true, "success",clsLectureService.listLectureBySubjectOrderCreateTime(subjectId, CommonUtils.getClassId(classId), sort, pager));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡ÆäËû¿Î¼þͳ¼Æ
|
*
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡ÆäËû¿Î¼þͳ¼Æ")
|
@GetMapping(value = "/app/otherLectureCount")
|
public Result otherLectureCount() {
|
return new Result(true, "success", CollectionUtils.newObjectMap("topicCount",
|
topicService.getClassTopicCount(ClientUtils.getClassId()), "evaluate", this.evaluateService.queryStuEvaluateCount()));
|
}
|
|
/**
|
*
|
* ѧϰ¶Ë»ñÈ¡¿Î³ÌÁбí
|
*
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡¿Î³ÌÏ¿μþ£¬°´Ä¿Â¼·ÖÀà", notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "subjectId", value = "¿Î³Ìid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "type", value = "¿Î¼þÀàÐÍ", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "/app/coursewareList")
|
public Result coursewareList(String classId,String subjectId, String type) {
|
classId = CommonUtils.getClassId(classId);
|
|
if(StringUtils.isEmpty(subjectId)) {
|
return new Result(false, "¿Î³Ìid²»ÄÜΪ¿Õ");
|
}
|
|
return this.clsLectureService.coursewareChapterList(classId, subjectId, type);
|
|
}
|
|
/**
|
* ÎҵĹ«¿ª¿ÎÁбí
|
*
|
*/
|
@ApiOperation(value = "ÎҵĹ«¿ª¿ÎÁбí", notes = "")
|
@GetMapping(value = "/app/myOpenSubjectList")
|
public Result myOpenSubjectList(Pager pager, @RequestParam(defaultValue = "")String keyword) {
|
return new Result(true, "success", this.subjectService.myOpenSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
|
}
|
|
/**
|
* ¹«¿ª¿ÎÁбí
|
*
|
*/
|
@ApiOperation(value = "¹«¿ª¿ÎÁбí", notes = "")
|
@GetMapping(value = "/app/openSubjectList")
|
public Result openSubjectList(Pager pager, @RequestParam(defaultValue = "")String keyword) {
|
return new Result(true, "success", this.subjectService.openSubjectList(pager.getOffset(), pager.getPageSize(), keyword));
|
}
|
|
/**
|
* ¹«¿ª¿ÎÏêÇé
|
*
|
*/
|
@ApiOperation(value = "¹«¿ª¿ÎÏêÇé", notes = "")
|
@GetMapping(value = "/app/openSubjectInfo")
|
public Result openSubjectInfo(@RequestParam(defaultValue = "")String subjectId) {
|
return new Result(true, "success", this.subjectService.openSubjectInfo(subjectId));
|
}
|
|
//--------------------------------------------------------ºǫ́¶Ë½Ó¿Ú---------------------------------------------------------------------------------------------------
|
|
/**
|
* ¼ÓÔØ¿Î¼þtree
|
*/
|
@ApiOperation(value = "¼ÓÔØ¿Î¼þtree", notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "subjectId", value = "°à¼¶id", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "categoryTree")
|
public Result categoryTree(String subjectId, String parentId) {
|
// classId = StringUtils.isEmpty(classId)?ClientUtils.getClassId():classId;
|
List<SubjectProgressTreeV> chapterLst = clsLectureService.getChapterTreeVList(subjectId, parentId);
|
|
for (SubjectProgressTreeV v : chapterLst) {
|
v.setNodeName(v.getNodeName() + "(" + String.format("%.2f", v.getPercent()*100) + "%)"); //±£ÁôÁ½Î»Ð¡Êý
|
}
|
|
return new Result(true, "success", QBeanUtils.listBean2ListMap(chapterLst, CollectionUtils
|
.newStringMap("nodeName", "name", "id.nodeId", "id", "parentId", "parentId", "percent", "percent")));
|
}
|
|
/**
|
* ѧϰ¶Ë»ñÈ¡ ËùÓпμþ
|
*
|
* @param classId
|
* @return ״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
|
*/
|
@ApiOperation(value = "ѧϰ¶Ë»ñÈ¡ ËùÓпμþ", notes = "״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "subjectId", value = "°à¼¶id", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "getCoursewareLstByClassId")
|
public Result getCoursewareLst(String subjectId) {
|
List<ClsSubjectLecture> lectureLst = clsLectureService.listLecture(subjectId);
|
|
// idΪС½Úid //·µ»ØµÄÊý¾Ý°´ÕÕtreeµÄС½ÚÅÅÐò
|
return new Result(true, "success",
|
|
QBeanUtils.listBean2ListMap(lectureLst, CollectionUtils.newStringMap("name", "name", "lectureId", "id",
|
"lectureType", "type", "chapterId", "chapterId")));
|
}
|
|
/**
|
* »ñÈ¡¿Î¼þÁбí
|
*
|
* @param chapterId
|
* Õ½Úid
|
* @param type
|
* ¿Î¼þÀàÐÍ
|
* @param keyword
|
* ËÑË÷¹Ø¼ü×Ö
|
* @param limit
|
* ÿҳÏÔʾ¼¸Ìõ
|
* @param pageNum
|
* Ò³Âë
|
* @return ״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)
|
*/
|
@ApiOperation(value = "¸ù¾ÝÕ½ڻñÈ¡¿Î¼þÁбí", notes = "״̬˵Ã÷(0,ÊÓÆµ¡£1,ÒôƵ¡£2,Îĵµ¡£3,Á·Ï°¡£)")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "chapterId", value = "Õ½Úid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "type", value = "¿Î¼þÀàÐÍ", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "coursewareListByChapterId")
|
public Result coursewareList(String chapterId, String type, String keyword, Integer limit, @RequestParam(defaultValue="1")Integer pageNum) {
|
|
List<MyLectureV> lectures = clsLectureService.listLectureV(ClientUtils.getUserId(), chapterId, keyword, limit,
|
pageNum, type);
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("coursewareLst",
|
QBeanUtils.listBean2ListMap(lectures,
|
CollectionUtils.newStringMap("lectureName", "name", "id.lectureId", "id", "lectureType",
|
"type", "lectureUpdateTime", "endUpdateTime", "percent", "percent"))));
|
|
}
|
|
/**
|
* ¿Î¼þѧϰ½ø¶ÈÌá½» stu/subject/study
|
*
|
* @param lectureId
|
* ¿Î¼þid
|
* @param from
|
* ¿ªÊ¼Ñ§Ï°Î»Öà £¬ÈçÊÓÆµ£¬ÔòΪʱ·ÖÃë(00:10:12),ÈçÎĵµ£¬ÔòÎÞÐèÌá½»¸Ã²ÎÊý
|
* @param to
|
* ½áÊøÑ§Ï°Î»Öã¬Í¬to
|
*/
|
@ApiOperation(value = "Ìύѧϰ½ø¶È")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "lectureId", value = "¿Î¼þid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "from", value = "¿ªÊ¼Ñ§Ï°Î»Öà £¬ÈçÊÓÆµ£¬ÔòΪʱ·ÖÃë(00:10:12),ÈçÎĵµ£¬ÔòÎÞÐèÌá½»¸Ã²ÎÊý", required = true, paramType="query", dataType = "Double"),
|
@ApiImplicitParam(name = "to", value = "½áÊøÑ§Ï°Î»Öã¬Í¬to", required = true, paramType="query", dataType = "Double"),
|
@ApiImplicitParam(name = "subjectId", value = "¿Î³Ìid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "lectureParentId", value = "¸¸¿Î¼þid", required = false, paramType="query", dataType = "String"),
|
})
|
@GetMapping(value = "study")
|
public Result study(String lectureId, @RequestParam(defaultValue = "1") Double from,
|
@RequestParam(defaultValue = "0") Double to, String subjectId, String classId, String lectureParentId) {
|
String userId = ClientUtils.getUserId();
|
classId = CommonUtils.getClassId(classId);
|
progressDao.putStudyById(userId, subjectId, lectureId, lectureParentId, classId);// ¼Ç¼ѧԱÿ¸ö¿Î³ÌµÄѧϰλÖÃ;
|
progressDao.putStudyByUserId(userId, subjectId, lectureId, lectureParentId, classId);// ¼Ç¼ѧԱÉÏ´ÎѧϰµÄλÖÃ;
|
return clsLectureService.doStudy(lectureId, from, to);
|
}
|
|
/**
|
* ÒôƵʱ³¤Ìá½» stu/subject/submitAudioDuration
|
*
|
* @param lectureId
|
* ¿Î¼þid
|
* @param seconds
|
* ʱ³¤
|
*/
|
@ApiOperation(value = "ÒôƵʱ³¤Ìá½»")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "lectureId", value = "¿Î¼þid", required = true, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "seconds", value = "ʱ³¤", required = true, paramType="query", dataType = "Double")
|
})
|
@CacheEvict(value = "LectureAudioV", key = "#lectureId")
|
@GetMapping(value = "submitAudioDuration")
|
public Result submitAudioDuration(String lectureId, double seconds) {
|
|
LectureAudioV audio = lectureService.readAudioLecture(lectureId);
|
|
return audioService.updateDuration(audio.getAudioId(), (int) seconds);
|
|
}
|
|
/**
|
* ¿Î³ÌÁбí
|
*
|
* @param clssId
|
* °à¼¶id
|
* @param startTime
|
* ¿ª°àʱ¼ä
|
*/
|
@ApiOperation(value = "¿Î³ÌÁбí")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "classId", value = "°à¼¶id", required = false, paramType="query", dataType = "String"),
|
@ApiImplicitParam(name = "startTime", value = "¿ª°àʱ¼ä", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "getSubjectLst")
|
public Result getList(String classId, String startTime, Integer limit, @RequestParam(defaultValue="1")Integer pageNum, HttpServletRequest request) {
|
// System.out.println("Óû§id"+request.getSession().getAttribute("userId"));
|
Object userId = request.getSession().getAttribute("userId");
|
classId = StringUtils.isEmpty(classId)?ClientUtils.getClassId():classId;
|
List<MySubjectV> result = subjectService.listMySubjectV(classId,String.valueOf(userId));
|
return new Result(true, "success",
|
QBeanUtils.listBean2ListMap(result,
|
CollectionUtils.newStringMap("id.subjectId", "subjectId", "id.classId", "classId",
|
"subjectName", "subjectName,coursewareName", "percent", "percent", "progressValue",
|
"studyTime", "coverPageUrl", "coverPageUrl")));
|
|
}
|
|
/**
|
* ½øÈë¿Î³Ì
|
*
|
* @param subjectId
|
* ¿Î³Ìid
|
*/
|
@ApiOperation(value = "¿Î³ÌÏêÇé")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "subjectId", value = "¿Î³Ìid", required = false, paramType="query", dataType = "String")
|
})
|
@GetMapping(value = "getSubjectDetail")
|
public Result getSubjectDetail(String subjectId) {
|
MySubjectV subject = subjectService.getMy1stSubjectVById(subjectId);
|
|
List<Map<String, Object>> progressLst = subjectService.listChapterStudyProgress(subjectId);
|
|
return new Result(true, "success",
|
CollectionUtils.newObjectMap("subject", QBeanUtils.bean2Map(subject,
|
CollectionUtils.newStringMap("subjectName", "subjectName", "id.subjectId", "subjectId",
|
"progressValue", "studyTime", "percent", "percent", "coverPageUrl", "coverPageUrl")),
|
"chapterLst",progressLst));
|
}
|
|
}
|