mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-07 17:55:59 +08:00
修复后台显示的学员线上课初次学习时间不准确bug
This commit is contained in:
parent
82c53ed87f
commit
23ff7068f7
@ -515,6 +515,10 @@ public class UserController {
|
||||
UserCourseHourRecordCourseCountMapper::getCourseId,
|
||||
UserCourseHourRecordCourseCountMapper::getTotal));
|
||||
|
||||
// 获取学员每个课程最早的学习课时记录
|
||||
List<UserCourseHourRecord> perCourseEarliestRecords =
|
||||
userCourseHourRecordService.getUserPerCourseEarliestRecord(id);
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("open_courses", openCourses);
|
||||
data.put("departments", departments);
|
||||
@ -524,6 +528,10 @@ public class UserController {
|
||||
userCourseRecords.stream()
|
||||
.collect(Collectors.toMap(UserCourseRecord::getCourseId, e -> e)));
|
||||
data.put("user_course_hour_count", userCourseHourCount);
|
||||
data.put(
|
||||
"per_course_earliest_records",
|
||||
perCourseEarliestRecords.stream()
|
||||
.collect(Collectors.toMap(UserCourseHourRecord::getCourseId, e -> e)));
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
@ -48,4 +48,6 @@ public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRec
|
||||
List<UserCourseHourRecord> paginate(UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId);
|
||||
}
|
||||
|
@ -66,4 +66,6 @@ public interface UserCourseHourRecordService extends IService<UserCourseHourReco
|
||||
|
||||
PaginationResult<UserCourseHourRecord> paginate(
|
||||
int page, int size, UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class UserCourseHourRecordServiceImpl
|
||||
@Override
|
||||
public List<UserCourseHourRecordCourseCountMapper> getUserCourseHourCount(
|
||||
Integer userId, List<Integer> courseIds, Integer isFinished) {
|
||||
if (courseIds == null || courseIds.size() == 0) {
|
||||
if (courseIds == null || courseIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getBaseMapper().getUserCourseHourCount(userId, courseIds, isFinished);
|
||||
@ -132,7 +132,7 @@ public class UserCourseHourRecordServiceImpl
|
||||
@Override
|
||||
public List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||
Integer courseId, List<Integer> userIds, Integer isFinished) {
|
||||
if (userIds == null || userIds.size() == 0) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getBaseMapper().getUserCourseHourUserCount(courseId, userIds, isFinished);
|
||||
@ -174,9 +174,14 @@ public class UserCourseHourRecordServiceImpl
|
||||
@Override
|
||||
public List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||
Integer courseId, List<Integer> userIds) {
|
||||
if (userIds == null || userIds.size() == 0) {
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getBaseMapper().getUserCourseHourUserFirstCreatedAt(courseId, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId) {
|
||||
return getBaseMapper().getUserPerCourseEarliestRecord(userId);
|
||||
}
|
||||
}
|
||||
|
@ -128,6 +128,7 @@
|
||||
</if>
|
||||
GROUP BY `user_id`;
|
||||
</select>
|
||||
|
||||
<select id="getUserCourseHourUserFirstCreatedAt"
|
||||
resultType="xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper">
|
||||
SELECT `t1`.`created_at`, `t1`.`user_id`
|
||||
@ -146,4 +147,25 @@
|
||||
AND `t1`.`user_id` IN (<foreach collection="userIds" item="userId" separator=",">#{userId}</foreach>)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getUserPerCourseEarliestRecord" 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
|
||||
`user_id` = #{userId}
|
||||
GROUP BY
|
||||
`user_id`,
|
||||
`course_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