mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-23 09:39:33 +08:00
新增后台学员的全部线上课进度api
This commit is contained in:
parent
51e077afb9
commit
abf6a36c4f
@ -409,7 +409,7 @@ public class UserController {
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
|
||||
@GetMapping("/{id}/learn-courses")
|
||||
public JsonResponse learnCourses(
|
||||
public JsonResponse latestLearnCourses(
|
||||
@PathVariable(name = "id") Integer id, @RequestParam HashMap<String, Object> params) {
|
||||
Integer page = MapUtils.getInteger(params, "page", 1);
|
||||
Integer size = MapUtils.getInteger(params, "size", 10);
|
||||
@ -442,6 +442,58 @@ public class UserController {
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
|
||||
@GetMapping("/{id}/all-courses")
|
||||
public JsonResponse allCourses(@PathVariable(name = "id") Integer id) {
|
||||
// 读取学员关联的部门
|
||||
List<Integer> depIds = userService.getDepIdsByUserId(id);
|
||||
List<Department> departments = new ArrayList<>();
|
||||
HashMap<Integer, List<Course>> depCourses = new HashMap<>();
|
||||
List<Integer> courseIds = new ArrayList<>();
|
||||
|
||||
if (depIds != null && depIds.size() > 0) {
|
||||
departments = departmentService.chunk(depIds);
|
||||
depIds.forEach(
|
||||
(depId) -> {
|
||||
List<Course> tmpCourses =
|
||||
courseService.getDepCoursesAndShow(
|
||||
new ArrayList<>() {
|
||||
{
|
||||
add(depId);
|
||||
}
|
||||
});
|
||||
depCourses.put(depId, tmpCourses);
|
||||
|
||||
if (tmpCourses != null && tmpCourses.size() > 0) {
|
||||
courseIds.addAll(tmpCourses.stream().map(Course::getId).toList());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 未关联部门课程
|
||||
List<Course> openCourses = courseService.getOpenCoursesAndShow(1000);
|
||||
if (openCourses != null && openCourses.size() > 0) {
|
||||
courseIds.addAll(openCourses.stream().map(Course::getId).toList());
|
||||
}
|
||||
|
||||
// 读取学员的线上课学习记录
|
||||
List<UserCourseRecord> userCourseRecords = new ArrayList<>();
|
||||
if (courseIds.size() > 0) {
|
||||
userCourseRecords = userCourseRecordService.chunk(id, courseIds);
|
||||
}
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("open_courses", openCourses);
|
||||
data.put("departments", departments);
|
||||
data.put("dep_courses", depCourses);
|
||||
data.put(
|
||||
"user_course_records",
|
||||
userCourseRecords.stream()
|
||||
.collect(Collectors.toMap(UserCourseRecord::getCourseId, e -> e)));
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_LEARN)
|
||||
@GetMapping("/{id}/learn-course/{courseId}")
|
||||
@SneakyThrows
|
||||
|
@ -64,4 +64,6 @@ public interface DepartmentService extends IService<Department> {
|
||||
Long total();
|
||||
|
||||
Map<Integer, Integer> getDepartmentsUserCount();
|
||||
|
||||
List<Department> chunk(List<Integer> ids);
|
||||
}
|
||||
|
@ -214,6 +214,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
|
||||
@Override
|
||||
public List<Course> getDepCoursesAndShow(List<Integer> depIds) {
|
||||
if (depIds == null || depIds.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepIds(depIds);
|
||||
if (courseIds == null || courseIds.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
|
@ -268,4 +268,12 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
DepartmentsUserCountMapRes::getDepId,
|
||||
DepartmentsUserCountMapRes::getTotal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Department> chunk(List<Integer> ids) {
|
||||
if (ids == null || ids.size() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return list(query().getWrapper().in("id", ids));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user