API-INFO-021 P1 | 学习历史记录接口 【status:todo】 #132

Closed
opened 2026-06-07 11:22:54 +08:00 by wangdl · 3 comments
Owner

目标

GET /learning/records?cursor=&limit=20&type=reading

返回

{ "items": [{id, recordType, title, durationSeconds, materialId, knowledgeBaseId, createdAt}], "nextCursor": null }

规则

  • 支持分页(cursor 方式)
  • 支持按 recordType 过滤
  • 只返回当前用户数据
  • 按 createdAt DESC

验收标准

  1. 支持分页
  2. 支持 recordType 过滤
  3. 只返回当前用户数据
## 目标 ```http GET /learning/records?cursor=&limit=20&type=reading ``` ## 返回 ```json { "items": [{id, recordType, title, durationSeconds, materialId, knowledgeBaseId, createdAt}], "nextCursor": null } ``` ## 规则 - 支持分页(cursor 方式) - 支持按 recordType 过滤 - 只返回当前用户数据 - 按 createdAt DESC ## 验收标准 1. 支持分页 2. 支持 recordType 过滤 3. 只返回当前用户数据
wangdl added this to the M8:学习信息收集与基础分析闭环 milestone 2026-06-07 11:22:54 +08:00
wangdl changed title from API-INFO-021 P1 | 学习历史记录接口 to API-INFO-021 P1 | 学习历史记录接口 【status:todo】 2026-06-07 19:04:18 +08:00
Author
Owner

审查结论:当前 API 项目学习信息收集体系基本为全新建设。可复用:JWT Guard、LearningSession 基础表/CRUD、DailyLearningActivity 基础表、ActivityController 部分接口、LearningRecord schema。其余 ReadingEvent/TemporaryMaterial/Progress/批量上报/Processor/聚合/查询接口/错误码/去重/权限/测试/文档均不存在或仅部分存在。

本 Issue: 接口不存在。blocked-by:api-info-core

标签: audit:reviewed audit:api-info status:todo work:api

## 审查结论:当前 API 项目学习信息收集体系基本为全新建设。可复用:JWT Guard、LearningSession 基础表/CRUD、DailyLearningActivity 基础表、ActivityController 部分接口、LearningRecord schema。其余 ReadingEvent/TemporaryMaterial/Progress/批量上报/Processor/聚合/查询接口/错误码/去重/权限/测试/文档均不存在或仅部分存在。 **本 Issue**: 接口不存在。blocked-by:api-info-core **标签**: audit:reviewed audit:api-info status:todo work:api
Author
Owner

实现提醒(来自 Batch A 审查 F3)

LearningRecordService.findByUser() 当前不返回分页总数(total count),实现学习历史记录接口时需补齐。

代码位置:src/modules/learning-record/learning-record.service.ts:42-56

## 实现提醒(来自 Batch A 审查 F3) `LearningRecordService.findByUser()` 当前不返回分页总数(total count),实现学习历史记录接口时需补齐。 代码位置:`src/modules/learning-record/learning-record.service.ts:42-56`
Author
Owner

完成报告

交付

GET /learning/records?cursor=&limit=20&type=reading — 学习历史记录:

{
  "items": [
    {
      "id": "cuid_rec_001",
      "recordType": "reading",
      "title": "Reading started",
      "description": null,
      "durationSeconds": 120,
      "occurredAt": "2026-01-01T00:00:00Z",
      "metadata": { "materialId": "...", "readingTargetType": "knowledge_source", ... },
      "createdAt": "2026-01-01T00:00:00Z"
    }
  ],
  "nextCursor": "cuid_rec_021"  // null if last page
}

分页:Cursor-based(基于 id)

  • limit 默认 20,最大 50
  • cursor 可选,首次请求不传
  • nextCursor 为最后一条记录 id,传回下次请求的 cursor 参数

过滤

  • type=reading 过滤 recordType
  • 只返回当前 userId 数据
  • 按 occurredAt DESC 排序

改动

  • LearningRecordService.findByUser 新增 cursor 模式
  • ReadingController.getRecords — 新端点
## 完成报告 ### 交付 **`GET /learning/records?cursor=&limit=20&type=reading`** — 学习历史记录: ```json { "items": [ { "id": "cuid_rec_001", "recordType": "reading", "title": "Reading started", "description": null, "durationSeconds": 120, "occurredAt": "2026-01-01T00:00:00Z", "metadata": { "materialId": "...", "readingTargetType": "knowledge_source", ... }, "createdAt": "2026-01-01T00:00:00Z" } ], "nextCursor": "cuid_rec_021" // null if last page } ``` **分页**:Cursor-based(基于 id) - `limit` 默认 20,最大 50 - `cursor` 可选,首次请求不传 - `nextCursor` 为最后一条记录 id,传回下次请求的 cursor 参数 **过滤**: - `type=reading` 过滤 recordType - 只返回当前 userId 数据 - 按 occurredAt DESC 排序 **改动**: - `LearningRecordService.findByUser` 新增 cursor 模式 - `ReadingController.getRecords` — 新端点
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#132
No description provided.