API-INFO-007 P0 | 新增 LearningRecord 模块 【status:partial】 #119

Closed
opened 2026-06-07 11:03:40 +08:00 by wangdl · 2 comments
Owner

目标

Prisma schema 有 LearningRecord 表但无 service/repository。完整版需完整实现。

Repository 方法

  • createRecord(), findByUser(), findBySessionId(), deleteById()

recordType

  • reading, review, quiz, chat, note, manual

详见设计文档 API-INFO-000。

## 目标 Prisma schema 有 LearningRecord 表但无 service/repository。完整版需完整实现。 ### Repository 方法 - createRecord(), findByUser(), findBySessionId(), deleteById() ### recordType - reading, review, quiz, chat, note, manual 详见设计文档 API-INFO-000。
wangdl added this to the M8:学习信息收集与基础分析闭环 milestone 2026-06-07 11:03:40 +08:00
wangdl changed title from API-INFO-014 P1 | 写入 LearningRecord 阅读记录 to API-INFO-014 P2 | 写入 LearningRecord 阅读记录 2026-06-07 11:16:48 +08:00
wangdl changed title from API-INFO-014 P2 | 写入 LearningRecord 阅读记录 to API-INFO-007 P0 | 新增 / 完善 LearningRecord 模块 2026-06-07 11:22:15 +08:00
wangdl changed title from API-INFO-007 P0 | 新增 / 完善 LearningRecord 模块 to API-INFO-007 P0 | 新增 LearningRecord 模块 【status:partial】 2026-06-07 19:04:11 +08:00
Author
Owner

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

本 Issue: Prisma schema 存在但无 service/repository 代码。

标签: audit:reviewed audit:api-info status:partial work:extend-existing

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

完成报告

交付

src/modules/learning-record/ — NestJS 模块:

1. learning-record.service.ts — 完整 CRUD:

class LearningRecordService {
  create({ userId, recordType, title, description?, sessionId?, durationSeconds?, occurredAt?, metadata? })
  findByUser(userId, { page?, limit?, recordType? })  // 分页 + 按类型过滤
  findBySessionId(sessionId)                            // session 维度查询
  deleteById(id, userId)                                // userId 鉴权删除
  createReadingRecord({ userId, sessionId?, materialId, ... }) // M8 便捷方法
}

2. recordType 取值

const LEARNING_RECORD_TYPES = [
  "reading",          // 阅读记录(M8 新增)
  "read_completed",   // 完成阅读(M8 新增)
  "review",           // 复习
  "quiz",             // 测验
  "chat",             // AI 对话
  "note",             // 笔记
  "manual",           // 手动记录
];

3. createReadingRecord() metadata 格式

{
  "materialId": "...",
  "readingTargetType": "knowledge_source",
  "knowledgeBaseId": "...",
  "totalActiveSeconds": 120,
  "lastPosition": { "type": "Markdown", "blockId": "ch1", "scrollProgress": 0.5 }
}
## 完成报告 ### 交付 `src/modules/learning-record/` — NestJS 模块: **1. `learning-record.service.ts`** — 完整 CRUD: ```typescript class LearningRecordService { create({ userId, recordType, title, description?, sessionId?, durationSeconds?, occurredAt?, metadata? }) findByUser(userId, { page?, limit?, recordType? }) // 分页 + 按类型过滤 findBySessionId(sessionId) // session 维度查询 deleteById(id, userId) // userId 鉴权删除 createReadingRecord({ userId, sessionId?, materialId, ... }) // M8 便捷方法 } ``` **2. `recordType` 取值**: ```typescript const LEARNING_RECORD_TYPES = [ "reading", // 阅读记录(M8 新增) "read_completed", // 完成阅读(M8 新增) "review", // 复习 "quiz", // 测验 "chat", // AI 对话 "note", // 笔记 "manual", // 手动记录 ]; ``` **3. `createReadingRecord()` metadata 格式**: ```json { "materialId": "...", "readingTargetType": "knowledge_source", "knowledgeBaseId": "...", "totalActiveSeconds": 120, "lastPosition": { "type": "Markdown", "blockId": "ch1", "scrollProgress": 0.5 } } ```
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#119
No description provided.