mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-20 19:02:48 +08:00
新增:课时详情apic
This commit is contained in:
parent
78386a289e
commit
fdb4c9ad73
@ -28,6 +28,7 @@ import xyz.playedu.api.caches.UserCanSeeCourseCache;
|
||||
import xyz.playedu.api.domain.*;
|
||||
import xyz.playedu.api.request.frontend.CourseHourRecordRequest;
|
||||
import xyz.playedu.api.service.CourseHourService;
|
||||
import xyz.playedu.api.service.CourseService;
|
||||
import xyz.playedu.api.service.ResourceService;
|
||||
import xyz.playedu.api.service.UserCourseHourRecordService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
@ -43,6 +44,8 @@ import java.util.HashMap;
|
||||
@RequestMapping("/api/v1/course/{courseId}/hour")
|
||||
public class HourController {
|
||||
|
||||
@Autowired private CourseService courseService;
|
||||
|
||||
@Autowired private CourseHourService hourService;
|
||||
|
||||
@Autowired private ResourceService resourceService;
|
||||
@ -55,6 +58,28 @@ public class HourController {
|
||||
@Autowired private UserCanSeeCourseCache userCanSeeCourseCache;
|
||||
@Autowired private CourseCache courseCache;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@SneakyThrows
|
||||
public JsonResponse detail(
|
||||
@PathVariable(name = "courseId") Integer courseId,
|
||||
@PathVariable(name = "id") Integer id) {
|
||||
Course course = courseService.findOrFail(courseId);
|
||||
CourseHour courseHour = hourService.findOrFail(id, courseId);
|
||||
|
||||
UserCourseHourRecord userCourseHourRecord = null;
|
||||
if (FCtx.getId() != null && FCtx.getId() > 0) {
|
||||
// 学员已登录
|
||||
userCourseHourRecord = userCourseHourRecordService.find(FCtx.getId(), courseId, id);
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("course", course);
|
||||
data.put("hour", courseHour);
|
||||
data.put("user_hour_record", userCourseHourRecord);
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/play")
|
||||
@SneakyThrows
|
||||
public JsonResponse play(
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package xyz.playedu.api.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@ -33,7 +31,6 @@ import xyz.playedu.api.service.UserCourseRecordService;
|
||||
* @create 2023/3/20 17:41
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class UserCourseHourFinishedListener {
|
||||
|
||||
@Autowired private UserCourseRecordService userCourseRecordService;
|
||||
@ -49,13 +46,6 @@ public class UserCourseHourFinishedListener {
|
||||
Integer finishedCount =
|
||||
userCourseHourRecordService.getFinishedHourCount(
|
||||
evt.getUserId(), evt.getCourseId());
|
||||
log.info(
|
||||
"UserCourseHourFinishedListener courseId={} userId={} hourCount={}"
|
||||
+ " finishedCount={}",
|
||||
evt.getCourseId(),
|
||||
evt.getUserId(),
|
||||
hourCount,
|
||||
finishedCount);
|
||||
userCourseRecordService.storeOrUpdate(
|
||||
evt.getUserId(), evt.getCourseId(), hourCount, finishedCount);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user