错题管理系统提供RESTful API,支持用户认证、错题管理、学习管理、报告生成、LLM智能功能、变更流程和监控告警。
Base URL: http://localhost:3000/api
认证方式: JWT Token(Bearer Token)
用户注册
请求体:
{
"username": "string",
"password": "string",
"role": "student|parent|admin",
"name": "string",
"grade": "string (可选)",
"school": "string (可选)",
"phone": "string (可选)",
"email": "string (可选)"
}响应:
{
"status": "success",
"data": {
"user": {
"id": "uuid",
"username": "string",
"role": "string"
},
"token": "jwt-token"
}
}用户登录
请求体:
{
"username": "string",
"password": "string"
}响应:
{
"status": "success",
"data": {
"user": {
"id": "uuid",
"username": "string",
"role": "string"
},
"token": "jwt-token"
}
}刷新令牌
请求体:
{
"token": "string"
}响应:
{
"status": "success",
"data": {
"token": "new-jwt-token"
}
}用户登出
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"message": "Logged out successfully"
}获取当前用户信息
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"username": "string",
"role": "string",
"studentId": "uuid (可选)",
"parentId": "uuid (可选)"
}
}绑定学生-家长关系
请求头:
Authorization: Bearer <token>
请求体:
{
"studentId": "uuid"
}响应:
{
"status": "success",
"message": "Parent and student bound successfully",
"data": {
"parentId": "uuid",
"studentId": "uuid"
}
}解绑学生-家长关系
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"message": "Unlinked successfully"
}获取用户列表(管理员)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"username": "string",
"role": "string",
"createdAt": "timestamp"
}
]
}获取用户详情
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"username": "string",
"role": "string",
"studentId": "uuid (可选)",
"parentId": "uuid (可选)",
"createdAt": "timestamp"
}
}更新用户
请求头:
Authorization: Bearer <token>
请求体:
{
"username": "string (可选)",
"role": "string (可选)"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"username": "string",
"role": "string"
}
}删除用户(管理员)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"message": "User deleted successfully"
}获取错题列表
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"title": "string",
"content": "string",
"subject": "math|physics|chemistry",
"type": "choice|fill|answer",
"difficulty": 1,
"knowledgePoints": ["string"],
"imageUrl": "string",
"answer": "string",
"explanation": "string",
"studentId": "uuid",
"createdAt": "timestamp",
"updatedAt": "timestamp"
}
]
}获取错题详情
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"title": "string",
"content": "string",
"subject": "math|physics|chemistry",
"type": "choice|fill|answer",
"difficulty": 1,
"knowledgePoints": ["string"],
"imageUrl": "string",
"answer": "string",
"explanation": "string",
"studentId": "uuid",
"createdAt": "timestamp",
"updatedAt": "timestamp"
}
}创建错题
请求头:
Authorization: Bearer <token>
Content-Type: multipart/form-data
请求体:
title: string
content: string
subject: math|physics|chemistry
type: choice|fill|answer
difficulty: number
knowledgePoints: JSON string array
answer: string (可选)
explanation: string (可选)
image: file (可选)
响应:
{
"status": "success",
"data": {
"id": "uuid",
"title": "string",
"content": "string",
"subject": "string",
"type": "string",
"difficulty": 1,
"knowledgePoints": ["string"],
"imageUrl": "string",
"studentId": "uuid",
"createdAt": "timestamp"
}
}更新错题
请求头:
Authorization: Bearer <token>
请求体:
{
"title": "string (可选)",
"content": "string (可选)",
"subject": "string (可选)",
"type": "string (可选)",
"difficulty": 1,
"knowledgePoints": ["string"],
"answer": "string (可选)",
"explanation": "string (可选)"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"title": "string",
"content": "string"
}
}更新错题的错因标签(多维度错因体系)。标签白名单:审题不清 / 计算粗心 / 公式遗忘 / 方法缺失 / 其他;去重后最多 10 个,非法值被过滤。
请求头:
Authorization: Bearer <token>
请求体:
{
"tags": ["审题不清", "计算粗心"],
"mode": "merge"
}mode: "replace"全量替换;默认/"merge"与现有标签取并集(重做流程追加标注场景)。
响应:
{
"status": "success",
"data": {
"id": "uuid",
"errorTags": ["审题不清", "计算粗心"]
}
}删除错题
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"message": "Question deleted successfully"
}AI识别错题
请求头:
Authorization: Bearer <token>
Content-Type: multipart/form-data
请求体:
image: file (必填)
响应:
{
"status": "success",
"data": {
"question": {
"id": "uuid",
"title": "string",
"content": "string",
"subject": "string",
"type": "string",
"difficulty": 1,
"knowledgePoints": ["string"],
"answer": "string",
"explanation": "string",
"confidence": 0.85
},
"identification": {
"title": "string",
"content": "string",
"subject": "string",
"type": "string",
"difficulty": 1,
"knowledgePoints": ["string"],
"answer": "string",
"explanation": "string",
"confidence": 0.85
}
}
}搜索错题
请求头:
Authorization: Bearer <token>
查询参数:
studentId: string (可选)subject: string (可选)type: string (可选)difficulty: number (可选)knowledgePoint: string (可选)keyword: string (可选)
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"title": "string",
"content": "string",
"subject": "string"
}
]
}获取错题统计
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"total": 10,
"bySubject": [
{ "subject": "math", "count": 5 },
{ "subject": "physics", "count": 3 },
{ "subject": "chemistry", "count": 2 }
],
"byDifficulty": [
{ "difficulty": 1, "count": 3 },
{ "difficulty": 2, "count": 4 },
{ "difficulty": 3, "count": 3 }
]
}
}获取重做列表
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"type": "online|photo",
"answer": "string",
"isCorrect": true,
"feedback": "string",
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp"
}
]
}获取重做详情
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"type": "online|photo",
"answer": "string",
"isCorrect": true,
"feedback": "string",
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp"
}
}创建在线重做
请求头:
Authorization: Bearer <token>
请求体:
{
"questionId": "uuid",
"answer": "string"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"type": "online",
"answer": "string",
"isCorrect": false,
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp"
}
}创建拍照重做
请求头:
Authorization: Bearer <token>
Content-Type: multipart/form-data
请求体:
questionId: uuid
image: file
响应:
{
"status": "success",
"data": {
"redo": {
"id": "uuid",
"type": "photo",
"answer": "string",
"isCorrect": true,
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp"
},
"grading": {
"isCorrect": true,
"score": 85,
"feedback": "回答正确",
"confidence": 0.9
}
}
}批改重做
请求头:
Authorization: Bearer <token>
请求体:
{
"isCorrect": true,
"feedback": "string"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"isCorrect": true,
"feedback": "string"
}
}学生改判
请求头:
Authorization: Bearer <token>
请求体:
{
"isCorrect": true
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"isCorrect": true
}
}获取掌握列表
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"status": "new|learning|mastered",
"correctCount": 0,
"incorrectCount": 0,
"intervalLevel": 0,
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp",
"updatedAt": "timestamp"
}
]
}获取掌握详情
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"status": "new|learning|mastered",
"correctCount": 0,
"incorrectCount": 0,
"intervalLevel": 0,
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp",
"updatedAt": "timestamp"
}
}创建掌握记录
请求头:
Authorization: Bearer <token>
请求体:
{
"questionId": "uuid",
"studentId": "uuid"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"status": "new",
"correctCount": 0,
"incorrectCount": 0,
"intervalLevel": 0,
"questionId": "uuid",
"studentId": "uuid",
"createdAt": "timestamp"
}
}复习掌握记录
请求头:
Authorization: Bearer <token>
请求体:
{
"isCorrect": true
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"status": "learning",
"correctCount": 1,
"incorrectCount": 0,
"intervalLevel": 1,
"nextReviewDate": "timestamp"
}
}获取掌握统计
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"totalQuestions": 10,
"masteredQuestions": 3,
"learningQuestions": 5,
"newQuestions": 2,
"masteryRate": 30
}
}获取复习队列
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"status": "learning",
"nextReviewDate": "timestamp",
"question": {
"id": "uuid",
"title": "string",
"content": "string"
}
}
]
}获取顽固薄弱点列表(累计做错 ≥ 阈值且未掌握的错题,按错误次数降序;学生首页置顶 / 薄弱点画像页)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"incorrectCount": 4,
"isStubborn": true,
"stubbornMarkedAt": "timestamp",
"question": {
"id": "uuid",
"title": "string"
}
}
]
}复习调度器配置:轮次总数/间隔表由接口下发,学生端展示口径随配置渲染(前端不再双份硬编码)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"scheduler": "ebbinghaus",
"totalRungs": 5,
"intervals": [1, 2, 4, 7, 15]
}
}
scheduler取值ebbinghaus(静态艾宾浩斯间隔表,默认)或fsrs(按 DSR 记忆状态动态排程,间隔逐题计算;此时intervals仅作展示口径)。
获取相似题列表
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"content": "string",
"isApplicable": true,
"originalQuestionId": "uuid",
"createdAt": "timestamp"
}
]
}生成相似题
请求头:
Authorization: Bearer <token>
请求体:
{
"questionId": "uuid"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"content": "string",
"isApplicable": true,
"originalQuestionId": "uuid",
"createdAt": "timestamp"
}
}标记相似题为适用
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"isApplicable": true
}
}标记相似题为不适用
请求头:
Authorization: Bearer <token>
请求体:
{
"reason": "string (可选)"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"isApplicable": false,
"reason": "string"
}
}获取周报
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"weekStart": "timestamp",
"weekEnd": "timestamp",
"weakPoints": ["string"],
"totalQuestions": 20,
"masteredQuestions": 5,
"similarQuestionsGenerated": 3,
"totalRedos": 15,
"masteryRate": 25,
"userId": "uuid",
"createdAt": "timestamp"
}
}获取统计信息
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"totalQuestions": 50,
"totalRedos": 30,
"correctRedos": 20,
"accuracyRate": 66.67,
"masteryStats": {
"total": 50,
"mastered": 15,
"learning": 25,
"new": 10
},
"masteryRate": 30
}
}错因多维度标签画像(评审 C1 后 studentId 同时接受登录用户 id(users.id)与学生档案 id(students.id)):返回错因标签分布 + 按错误次数加权的薄弱知识点,供学生端与家长端「薄弱点画像」页使用。
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"totalQuestions": 50,
"taggedQuestions": 32,
"errorTagDistribution": [
{ "tag": "审题不清", "count": 12 },
{ "tag": "计算粗心", "count": 8 }
],
"weakKnowledgePoints": [
{ "point": "二次函数", "questionCount": 14, "incorrectCount": 9, "totalQuestions": 20 }
]
}
}获取日报
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"date": "2024-01-01",
"questionsAdded": 5,
"redosCompleted": 3,
"correctRedos": 2,
"masteryStats": {
"total": 50,
"mastered": 15,
"learning": 25
}
}
}大模型多题切分识别接口(同步兼容接口,建议改用异步接口,避免长请求触发 Nginx 504)。
- Header:
Content-Type: multipart/form-data - Body:
file(Buffer/Stream)
{
"status": "success",
"data": {
"items": [
{ "tempId": "...", "title": "...", "content": "...", "subject": "math", "type": "choice", "answer": "...", "explanation": "...", "isDuplicate": false }
]
}
}整页多题识别异步任务提交(推荐):立即返回 taskId,前端轮询进度与结果,消除 15-30s 同步挂起的 504 风险(见 docs/adr/0004)。
- Header:
Content-Type: multipart/form-data - Body:
file(Buffer/Stream)、subject(可选,默认 math)
{
"status": "success",
"data": {
"taskId": "<uuid>",
"statusUrl": "/api/questions/identify-multi/tasks/<uuid>"
}
}查询异步识别任务状态(轮询入口,建议 2 秒间隔,超时 10 分钟)。
{
"status": "success",
"data": {
"taskId": "<uuid>",
"state": "queued | processing | completed | failed",
"progress": 55,
"result": { "items": [ ... 同同步接口 items 结构 ... ] },
"error": "失败原因(仅 failed)"
}
}任务不存在或已过期(完成后 1 小时清理)返回 404。 获取LLM用量汇总
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"totalCalls": 100,
"successfulCalls": 95,
"failedCalls": 5,
"successRate": 95,
"sceneSummary": [
{ "scene": "recognition", "count": 50, "totalTokens": 10000 },
{ "scene": "grading", "count": 30, "totalTokens": 8000 },
{ "scene": "similar", "count": 20, "totalTokens": 5000 }
],
"modelSummary": [
{ "provider": "openai", "model": "gpt-4-vision", "count": 80 },
{ "provider": "anthropic", "model": "claude-3", "count": 20 }
]
}
}获取LLM配置
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"primary": {
"provider": "openai",
"model": "gpt-4o-mini",
"apiBase": "https://api.openai.com/v1"
},
"fallback": {
"provider": "anthropic",
"model": "claude-3-opus-20240229",
"apiBase": "https://api.anthropic.com"
},
"strategy": {
"enabled": true,
"retryCount": 2,
"timeoutMs": 30000
}
}
}获取变更列表
请求头:
Authorization: Bearer <token>
查询参数:
status: string (可选)type: string (可选)
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"title": "string",
"description": "string",
"type": "low|medium|high|urgent",
"priority": "low|medium|high",
"status": "pending|approved|rejected|in_progress|completed|deployed",
"creatorId": "uuid",
"createdAt": "timestamp",
"updatedAt": "timestamp"
}
]
}创建变更请求
请求头:
Authorization: Bearer <token>
请求体:
{
"title": "string",
"description": "string",
"type": "low|medium|high|urgent",
"priority": "low|medium|high"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"title": "string",
"description": "string",
"type": "string",
"priority": "string",
"status": "pending",
"creatorId": "uuid",
"createdAt": "timestamp"
}
}审批变更(管理员)
请求头:
Authorization: Bearer <token>
请求体:
{
"approvalNote": "string (可选)"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"status": "approved",
"approvalNote": "string",
"approvedBy": "uuid",
"approvedAt": "timestamp"
}
}拒绝变更(管理员)
请求头:
Authorization: Bearer <token>
请求体:
{
"approvalNote": "string (可选)"
}响应:
{
"status": "success",
"data": {
"id": "uuid",
"status": "rejected",
"approvalNote": "string",
"approvedBy": "uuid",
"approvedAt": "timestamp"
}
}健康检查(公开)
响应:
{
"status": "success",
"data": {
"database": {
"connected": true
},
"memory": {
"rss": 50000000,
"heapUsed": 30000000,
"heapTotal": 50000000
},
"uptime": 3600,
"timestamp": "2024-01-01T00:00:00.000Z"
}
}获取监控日志(管理员)
请求头:
Authorization: Bearer <token>
查询参数:
level: string (可选)type: string (可选)acknowledged: boolean (可选)
响应:
{
"status": "success",
"data": [
{
"id": "uuid",
"level": "info|warning|error|critical",
"type": "health_check|deployment|llm_usage|system_error|security",
"message": "string",
"details": "string",
"source": "string",
"acknowledged": false,
"createdAt": "timestamp"
}
]
}获取监控统计(管理员)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"total": 100,
"byLevel": [
{ "level": "info", "count": 80 },
{ "level": "warning", "count": 15 },
{ "level": "error", "count": 5 }
],
"byType": [
{ "type": "health_check", "count": 50 },
{ "type": "llm_usage", "count": 30 },
{ "type": "deployment", "count": 20 }
],
"recentErrors": [
{
"id": "uuid",
"message": "string",
"createdAt": "timestamp"
}
]
}
}确认监控日志(管理员)
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"id": "uuid",
"acknowledged": true,
"acknowledgedBy": "uuid",
"acknowledgedAt": "timestamp"
}
}获取系统统计
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"users": {
"total": 10,
"students": 5,
"parents": 4,
"admins": 1
},
"questions": {
"total": 100
},
"redos": {
"total": 50
},
"mastery": {
"total": 100
},
"llm": {
"totalCalls": 200,
"successfulCalls": 190,
"failedCalls": 10,
"successRate": 95
}
}
}获取系统健康状态
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": {
"database": {
"connected": true
},
"memory": {
"rss": 50000000,
"heapUsed": 30000000,
"heapTotal": 50000000
},
"uptime": 3600,
"timestamp": "2024-01-01T00:00:00.000Z"
}
}所有API错误响应格式:
{
"status": "error",
"statusCode": 400,
"message": "错误信息"
}常见错误码:
400- 请求参数错误401- 未认证或令牌无效403- 无权限404- 资源不存在500- 服务器内部错误
所有需要认证的API都需要在请求头中包含JWT Token:
Authorization: Bearer <your-jwt-token>
Token可以通过登录接口获取,有效期为7天。
API文档版本:v1.0.0 最后更新:2024-01-01
管理员重置/修改指定用户的密码。
请求头:
Authorization: Bearer <token>
请求体:
{
"password": "new_password_123456"
}响应:
{
"status": "success",
"data": {
"id": "3c9a7ef0-5709-4ba6-82bc-7666f707d40f",
"username": "test_student"
}
}按用户维度统计 LLM Token 用量分布(仅限管理员)。
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"userId": "3c9a7ef0-5709-4ba6-82bc-7666f707d40f",
"username": "test_student",
"role": "student",
"count": 24,
"tokensTotal": 77970,
"tokensInput": 60000,
"tokensOutput": 17970
}
]
}按日期维度统计近 7 天 / 近 30 天每日 LLM 调用与 Token 用量(仅限管理员)。
请求头:
Authorization: Bearer <token>
响应:
{
"status": "success",
"data": [
{
"date": "2026-08-09",
"count": 5,
"tokensTotal": 5752
}
]
}获取阶梯式引导提示(检索练习防剧透):按 1/2/3 级渐进生成——① 考点方向(不含公式)→ ② 思路台阶(不含方程)→ ③ 关键方程(不含最终答案);调用按 guidance 场景记账。需本人学生身份。
请求头:
Authorization: Bearer <token>
请求体:
{
"questionId": "uuid",
"level": 1
}响应:
{
"status": "success",
"data": {
"level": 1,
"hint": "本题考查……(不超过 100 字,不含公式)",
"nextLevel": 2
}
}错误响应:
400- level 不在 1–3 范围404- 题目不存在502- LLM 生成失败(前端提示稍后重试,不静默兑底泄露解析)