mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 10:56:50 +08:00
加了一个学习的方法
This commit is contained in:
@@ -6,6 +6,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -22,12 +24,23 @@ import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseSection;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseSectionService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.service.ICourseTeacherService;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
import com.xboe.module.teacher.service.ITeacherService;
|
||||
import com.xboe.school.study.dto.StudyContentDto;
|
||||
import com.xboe.school.study.dto.StudyCourseNameDto;
|
||||
import com.xboe.school.study.dto.StudyCourseQuery;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.entity.StudySignup;
|
||||
import com.xboe.school.study.entity.StudyTime;
|
||||
import com.xboe.school.study.service.IStudyCourseService;
|
||||
import com.xboe.school.study.service.IStudyService;
|
||||
@@ -52,6 +65,19 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
@Autowired
|
||||
ICourseService courseService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ICourseContentService contentService;
|
||||
|
||||
@Autowired
|
||||
private ICourseSectionService sectionService;
|
||||
|
||||
@Autowired
|
||||
private ICourseTeacherService courseTeacherService;
|
||||
|
||||
@Autowired
|
||||
private ITeacherService teacherService;
|
||||
|
||||
@Autowired
|
||||
IStudySignupService signupService;
|
||||
|
||||
@@ -106,6 +132,61 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 学习页面,加载课程的信息,用于替换portal中的detail方法
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/studyIndex",method = {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<Map<String,Object>> loadDetail(String id,Boolean addView,Boolean crowd){
|
||||
if(StringUtils.isBlank(id)){
|
||||
return error("无课程信息");
|
||||
}
|
||||
String aid=getCurrent().getAccountId();
|
||||
StudyCourse sc=service.findByCourseIdAndAid(id, aid);
|
||||
|
||||
|
||||
Map<String,Object> rs=new HashMap<String,Object>();
|
||||
Course course=courseService.getAddView(id);
|
||||
if(course==null || course.getDeleted()){
|
||||
return badRequest("课程不存在或已被删除");
|
||||
}
|
||||
rs.put("course",course);
|
||||
|
||||
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id);
|
||||
if(crowd!=null && crowd) {
|
||||
rs.put("crowds",courseCrowdList);
|
||||
}
|
||||
List<CourseContent> cclist=contentService.getByCourseId(id);
|
||||
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
|
||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
|
||||
|
||||
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
||||
for(CourseTeacher ct : teachers) {
|
||||
Teacher t = teacherService.get(ct.getTeacherId());
|
||||
if(t!=null) {
|
||||
ct.setRemark(t.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
rs.put("teachers",teachers);
|
||||
|
||||
//检查是否已报名
|
||||
StudySignup ss = signupService.getByCidAndAid(id, aid);
|
||||
if(ss!=null && ss.getStatus()!=null && ss.getStatus()==9) {
|
||||
rs.put("signup",true);
|
||||
}else {
|
||||
rs.put("signup",false);
|
||||
}
|
||||
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 检查是否有相应的课程学习
|
||||
// * @param cid
|
||||
|
||||
Reference in New Issue
Block a user