mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-08-20 12:29:30 +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.domain.*;
|
||||||
import xyz.playedu.api.request.frontend.CourseHourRecordRequest;
|
import xyz.playedu.api.request.frontend.CourseHourRecordRequest;
|
||||||
import xyz.playedu.api.service.CourseHourService;
|
import xyz.playedu.api.service.CourseHourService;
|
||||||
|
import xyz.playedu.api.service.CourseService;
|
||||||
import xyz.playedu.api.service.ResourceService;
|
import xyz.playedu.api.service.ResourceService;
|
||||||
import xyz.playedu.api.service.UserCourseHourRecordService;
|
import xyz.playedu.api.service.UserCourseHourRecordService;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
@ -43,6 +44,8 @@ import java.util.HashMap;
|
|||||||
@RequestMapping("/api/v1/course/{courseId}/hour")
|
@RequestMapping("/api/v1/course/{courseId}/hour")
|
||||||
public class HourController {
|
public class HourController {
|
||||||
|
|
||||||
|
@Autowired private CourseService courseService;
|
||||||
|
|
||||||
@Autowired private CourseHourService hourService;
|
@Autowired private CourseHourService hourService;
|
||||||
|
|
||||||
@Autowired private ResourceService resourceService;
|
@Autowired private ResourceService resourceService;
|
||||||
@ -55,6 +58,28 @@ public class HourController {
|
|||||||
@Autowired private UserCanSeeCourseCache userCanSeeCourseCache;
|
@Autowired private UserCanSeeCourseCache userCanSeeCourseCache;
|
||||||
@Autowired private CourseCache courseCache;
|
@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")
|
@GetMapping("/{id}/play")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public JsonResponse play(
|
public JsonResponse play(
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package xyz.playedu.api.listener;
|
package xyz.playedu.api.listener;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@ -33,7 +31,6 @@ import xyz.playedu.api.service.UserCourseRecordService;
|
|||||||
* @create 2023/3/20 17:41
|
* @create 2023/3/20 17:41
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
|
||||||
public class UserCourseHourFinishedListener {
|
public class UserCourseHourFinishedListener {
|
||||||
|
|
||||||
@Autowired private UserCourseRecordService userCourseRecordService;
|
@Autowired private UserCourseRecordService userCourseRecordService;
|
||||||
@ -49,13 +46,6 @@ public class UserCourseHourFinishedListener {
|
|||||||
Integer finishedCount =
|
Integer finishedCount =
|
||||||
userCourseHourRecordService.getFinishedHourCount(
|
userCourseHourRecordService.getFinishedHourCount(
|
||||||
evt.getUserId(), evt.getCourseId());
|
evt.getUserId(), evt.getCourseId());
|
||||||
log.info(
|
|
||||||
"UserCourseHourFinishedListener courseId={} userId={} hourCount={}"
|
|
||||||
+ " finishedCount={}",
|
|
||||||
evt.getCourseId(),
|
|
||||||
evt.getUserId(),
|
|
||||||
hourCount,
|
|
||||||
finishedCount);
|
|
||||||
userCourseRecordService.storeOrUpdate(
|
userCourseRecordService.storeOrUpdate(
|
||||||
evt.getUserId(), evt.getCourseId(), hourCount, finishedCount);
|
evt.getUserId(), evt.getCourseId(), hourCount, finishedCount);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user