返回线上课学员的学习记录最早的学习时间

This commit is contained in:
xxx
2023-11-15 10:07:51 +08:00
parent e8399362ea
commit 877aec3b01
5 changed files with 39 additions and 0 deletions

View File

@@ -50,4 +50,6 @@ public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRec
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
List<UserCourseHourRecord> getUserPerCourseEarliestRecord(Integer userId);
List<UserCourseHourRecord> getCoursePerUserEarliestRecord(Integer courseId);
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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>