mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-23 17:49:34 +08:00
课程附件列表查询
This commit is contained in:
parent
3aa2ea9990
commit
46015593e9
@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.*;
|
||||
import xyz.playedu.api.event.CourseDestroyEvent;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
@ -208,8 +209,8 @@ public class CourseController {
|
||||
data.put("dep_ids", depIds); // 已关联的部门
|
||||
data.put("category_ids", categoryIds); // 已关联的分类
|
||||
data.put("chapters", chapters);
|
||||
data.put("hours", hours.stream().collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
|
||||
data.put("hours", hours.stream().filter(courseHour -> BackendConstant.RESOURCE_TYPE_VIDEO.equals(courseHour.getType())).collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
data.put("attachments", hours.stream().filter(courseHour -> BackendConstant.RESOURCE_TYPE_ATTACHMENT.contains(courseHour.getType())).collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,6 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/api/v1/course")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired private ResourceService resourceService;
|
||||
|
||||
@Autowired private CourseService courseService;
|
||||
|
||||
@Autowired private CourseChapterService chapterService;
|
||||
@ -81,10 +79,21 @@ public class CourseController {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("course", course);
|
||||
data.put("chapters", chapterService.getChaptersByCourseId(course.getId()));
|
||||
data.put("hours", courseHours.stream().collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
data.put(
|
||||
"hours",
|
||||
courseHours.stream()
|
||||
.filter(courseHour -> BackendConstant.RESOURCE_TYPE_VIDEO.equals(courseHour.getType()))
|
||||
.collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
data.put("learn_record", userCourseRecordService.find(FCtx.getId(), course.getId()));
|
||||
data.put("learn_hour_records", userCourseHourRecordService.getRecords(FCtx.getId(), course.getId()).stream().collect(Collectors.toMap(UserCourseHourRecord::getHourId, e -> e)));
|
||||
data.put("resource_attachments", resourceService.chunks(courseHours.stream().map(CourseHour::getRid).collect(Collectors.toList())).stream().filter(resource -> BackendConstant.RESOURCE_TYPE_ATTACHMENT.contains(resource.getType())).collect(Collectors.toList()));
|
||||
data.put(
|
||||
"learn_hour_records",
|
||||
userCourseHourRecordService.getRecords(FCtx.getId(), course.getId()).stream()
|
||||
.collect(Collectors.toMap(UserCourseHourRecord::getHourId, e -> e)));
|
||||
data.put(
|
||||
"attachments",
|
||||
courseHours.stream()
|
||||
.filter(courseHour -> BackendConstant.RESOURCE_TYPE_ATTACHMENT.contains(courseHour.getType()))
|
||||
.collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user