mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-07 09:44:03 +08:00
返回线上课学员的学习记录最早的学习时间
This commit is contained in:
parent
e8399362ea
commit
877aec3b01
@ -36,6 +36,7 @@ import xyz.playedu.common.types.JsonResponse;
|
||||
import xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
|
||||
import xyz.playedu.common.types.paginate.PaginationResult;
|
||||
import xyz.playedu.common.types.paginate.UserPaginateFilter;
|
||||
import xyz.playedu.course.domain.UserCourseHourRecord;
|
||||
import xyz.playedu.course.domain.UserCourseRecord;
|
||||
import xyz.playedu.course.service.CourseService;
|
||||
import xyz.playedu.course.service.UserCourseHourRecordService;
|
||||
@ -141,6 +142,14 @@ public class CourseUserController {
|
||||
userService.getDepIdsGroup(result.getData().stream().map(User::getId).toList()));
|
||||
data.put("departments", departmentService.id2name());
|
||||
|
||||
// 获取每个学员的最早学习时间
|
||||
List<UserCourseHourRecord> perUserEarliestRecords =
|
||||
userCourseHourRecordService.getCoursePerUserEarliestRecord(courseId);
|
||||
data.put(
|
||||
"per_user_earliest_records",
|
||||
perUserEarliestRecords.stream()
|
||||
.collect(Collectors.toMap(UserCourseHourRecord::getUserId, e -> e)));
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
|
@ -50,4 +50,6 @@ public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRec
|
||||
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId);
|
||||
|
||||
List<UserCourseHourRecord> getCoursePerUserEarliestRecord(Integer courseId);
|
||||
}
|
||||
|
@ -68,4 +68,6 @@ public interface UserCourseHourRecordService extends IService<UserCourseHourReco
|
||||
int page, int size, UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId);
|
||||
|
||||
List<UserCourseHourRecord> getCoursePerUserEarliestRecord(Integer courseId);
|
||||
}
|
||||
|
@ -184,4 +184,9 @@ public class UserCourseHourRecordServiceImpl
|
||||
public List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId) {
|
||||
return getBaseMapper().getUserPerCourseEarliestRecord(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCourseHourRecord> getCoursePerUserEarliestRecord(Integer courseId) {
|
||||
return getBaseMapper().getCoursePerUserEarliestRecord(courseId);
|
||||
}
|
||||
}
|
||||
|
@ -168,4 +168,25 @@
|
||||
AND `b`.`course_id` = `a`.`course_id`
|
||||
AND `b`.`user_id` = `a`.`user_id`;
|
||||
</select>
|
||||
|
||||
<select id="getCoursePerUserEarliestRecord" resultType="xyz.playedu.course.domain.UserCourseHourRecord">
|
||||
SELECT
|
||||
`a`.*
|
||||
FROM
|
||||
`user_course_hour_records` AS `a`
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
min(`created_at`) AS `min_created_at`,
|
||||
`course_id`,
|
||||
`user_id`
|
||||
FROM
|
||||
`user_course_hour_records`
|
||||
WHERE
|
||||
`course_id` = #{courseId}
|
||||
GROUP BY
|
||||
`course_id`,
|
||||
`user_id`) AS `b` ON `b`.`min_created_at` = `a`.`created_at`
|
||||
AND `b`.`course_id` = `a`.`course_id`
|
||||
AND `b`.`user_id` = `a`.`user_id`;
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user