问题:题库 API 缺少 /questions/statistics 端点
解决方案:
app/main.py 添加 /questions/statistics 路由app/repositories.py 实现 get_statistics() 方法问题:
/questions 端点不支持 page 和 per_page 参数解决方案:
app/main.py 的 list_questions() 函数page、per_page、difficulty、search 参数支持app/repositories.py 实现 list_with_pagination() 方法{"data": [...], "meta": {...}}问题:.env 中 QUESTION_BANK_API_BASE 配置为端口 6001
解决方案:
.env:QUESTION_BANK_API_BASE=http://127.0.0.1:5015config:clear, cache:clear状态:✅ 完整保留
验证内容:
KnowledgePoints.php - 知识点总览页面存在KnowledgePointDetail.php - 知识点详情页面存在AdminPanelProvider.php 中正确注册所有页面admin/knowledge-points, admin/knowledge-point-detail# 统计 API
$ curl http://127.0.0.1:5015/questions/statistics
{
"total": 5,
"by_difficulty": {"0.3": 2, "0.6": 2, "0.85": 1},
"by_kp": {"KP0101": 5},
"by_source": {"AI 生成": 5}
}
# 分页列表 API
$ curl "http://127.0.0.1:5015/questions?page=1&per_page=5"
{
"data": [...],
"meta": {"page": 1, "per_page": 5, "total": 5, "total_pages": 1}
}
// 通过 artisan tinker 测试
$ php artisan tinker
> $api = app(App\Services\QuestionServiceApi::class);
> $list = $api->listQuestions(1, 5);
> count($list['data']);
=> 5
> $stats = $api->getStatistics();
> $stats['total'];
=> 5
> $stats['by_difficulty']['0.3'];
=> 2
结果:✅ 所有测试通过
| 服务 | 端口 | 状态 | 说明 |
|---|---|---|---|
| 题库 API | 5015 | ✅ 运行中 | FastAPI + PostgreSQL |
| 知识图谱 API | 5011 | ✅ 运行中 | FastAPI + JSON |
| Laravel 后台 | fa.test | ✅ 运行中 | Herd 开发服务器 |
| PostgreSQL | 5442 | ✅ 运行中 | 题库数据库 |
| 页面 | 路径 | 状态 | 菜单组 |
|---|---|---|---|
| 仪表盘 | /admin |
✅ 正常 | - |
| 知识点总览 | /admin/knowledge-points |
✅ 正常 | 知识图谱 |
| 知识点详情 | /admin/knowledge-point-detail |
✅ 正常 | 知识图谱 |
| 题库管理 | /admin/question-management |
✅ 正常 | 题库系统 |
GET /questions - 获取题目列表(支持分页和筛选)GET /questions/statistics - 获取统计信息POST /questions - 创建题目PATCH /questions/{code} - 更新题目DELETE /questions/{code} - 删除题目@app.get("/questions")
def list_questions(
page: int = Query(1, ge=1),
per_page: int = Query(25, ge=1, le=100),
kp_code: str | None = None,
difficulty: str | None = None,
search: str | None = None,
session: Session = Depends(get_session),
):
repo = QuestionRepository(session)
offset = (page - 1) * per_page
questions, total = repo.list_with_pagination(...)
return {
"data": questions,
"meta": {"page": page, "per_page": per_page, "total": total, ...}
}
public function listQuestions(int $page = 1, int $perPage = 50, array $filters = []): array
{
$response = $this->request('GET', '/questions', [
'page' => $page,
'per_page' => $perPage,
'kp_code' => $filters['kp_code'] ?? null,
'difficulty' => $filters['difficulty'] ?? null,
'search' => $filters['search'] ?? null,
]);
return [
'data' => $response['data'] ?? [],
'meta' => $response['meta'] ?? [...],
];
}
所有问题已解决:
系统运行状态:🟢 全部正常
访问地址:
报告生成时间:2025-11-15 状态:✅ 修复完成,系统正常运行