mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-07 01:34:05 +08:00
课程附件列表查询
This commit is contained in:
parent
0da1c9d0d2
commit
3aa2ea9990
@ -40,7 +40,7 @@ public class BackendConstant {
|
||||
public static final String RESOURCE_TYPE_RAR = "RAR";
|
||||
public static final String RESOURCE_TYPE_TXT = "TXT";
|
||||
|
||||
public static final String RESOURCE_TYPE_ANNEX =
|
||||
public static final String RESOURCE_TYPE_ATTACHMENT =
|
||||
RESOURCE_TYPE_PDF +","+ RESOURCE_TYPE_TXT +","+
|
||||
RESOURCE_TYPE_ZIP +","+ RESOURCE_TYPE_RAR +","+
|
||||
RESOURCE_TYPE_WORD +","+RESOURCE_TYPE_PPT +","+RESOURCE_TYPE_EXCEL;
|
||||
|
@ -111,7 +111,7 @@ public class ResourceController {
|
||||
|
||||
if(!type.equals(BackendConstant.RESOURCE_TYPE_VIDEO) &&
|
||||
!type.equals(BackendConstant.RESOURCE_TYPE_IMAGE)){
|
||||
filter.setType(BackendConstant.RESOURCE_TYPE_ANNEX);
|
||||
filter.setType(BackendConstant.RESOURCE_TYPE_ATTACHMENT);
|
||||
data.put("existingType",resourceService.paginateType(filter));
|
||||
}
|
||||
return JsonResponse.data(data);
|
||||
|
@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import xyz.playedu.api.FCtx;
|
||||
import xyz.playedu.api.constant.BackendConstant;
|
||||
import xyz.playedu.api.domain.Course;
|
||||
import xyz.playedu.api.domain.CourseHour;
|
||||
import xyz.playedu.api.domain.UserCourseHourRecord;
|
||||
@ -31,6 +32,7 @@ import xyz.playedu.api.types.paginate.CoursePaginateFiler;
|
||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -42,6 +44,8 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/api/v1/course")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired private ResourceService resourceService;
|
||||
|
||||
@Autowired private CourseService courseService;
|
||||
|
||||
@Autowired private CourseChapterService chapterService;
|
||||
@ -72,19 +76,15 @@ public class CourseController {
|
||||
public JsonResponse detail(@PathVariable(name = "id") Integer id) {
|
||||
Course course = courseService.findOrFail(id);
|
||||
|
||||
List<CourseHour> courseHours = hourService.getHoursByCourseId(course.getId());
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("course", course);
|
||||
data.put("chapters", chapterService.getChaptersByCourseId(course.getId()));
|
||||
data.put(
|
||||
"hours",
|
||||
hourService.getHoursByCourseId(course.getId()).stream()
|
||||
.collect(Collectors.groupingBy(CourseHour::getChapterId)));
|
||||
data.put("hours", courseHours.stream().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("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()));
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user