FilamentAdmin/
├── app/
│ ├── Models/
│ │ └── Question.php # 题目模型(备用)
│ │
│ ├── Services/
│ │ └── QuestionServiceApi.php # 题库 API 客户端 ✅
│ │
│ ├── Filament/
│ │ ├── Pages/
│ │ │ ├── KnowledgePoints.php # 知识点管理页
│ │ │ ├── KnowledgePointDetail.php # 知识点详情页
│ │ │ └── QuestionManagement.php # 题库管理页 ✅
│ │ │
│ │ ├── Resources/
│ │ │ └── QuestionResource.php # 题库资源(备用)
│ │ │ └── Pages/
│ │ │ ├── ListQuestions.php
│ │ │ ├── CreateQuestion.php
│ │ │ └── ViewQuestion.php
│ │ │
│ │ └── resources/views/filament/pages/
│ │ └── question-management.blade.php # 题库管理视图 ✅
│ │
│ └── Providers/Filament/
│ └── AdminPanelProvider.php # 已注册 QuestionManagement ✅
│
├── config/
│ └── question_bank.php # 题库配置 ✅
│
├── routes/
│ └── api.php # API 路由 ✅
│
└── .env.example # 已更新配置 ✅
QuestionManagement.php)✅ 已实现:
📊 数据展示:
QuestionServiceApi.php)✅ 功能:
listQuestions() - 获取题目列表(分页、筛选)getStatistics() - 获取统计信息searchQuestions() - 语义搜索getQuestionById() - 获取单个题目generateQuestions() - AI 生成题目deleteQuestion() - 删除题目getKnowledgePointOptions() - 获取知识点选项🔧 特性:
routes/api.php)✅ 端点:
GET /api/questions - 获取题目列表
GET /api/questions/statistics - 获取统计信息
POST /api/questions/search - 语义搜索
GET /api/questions/{id} - 获取题目详情
POST /api/questions/generate - AI 生成题目
DELETE /api/questions/{id} - 删除题目
GET /api/knowledge-points - 获取知识点选项
config/question_bank.php)✅ 配置项:
api_base - 题库 API 地址timeout - 请求超时时间cache_ttl - 缓存生存时间retry_attempts - 重试次数retry_delay - 重试延迟┌─────────────────────────────────────────────────────┐
│ 题库管理 [AI生成] [刷新] │
├─────────────────────────────────────────────────────┤
│ 统计信息卡片 │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │总数 0│ │基础 0│ │中等 0│ │拔高 0│ │
│ └──────┘ └──────┘ └──────┘ └──────┘ │
├─────────────────────────────────────────────────────┤
│ 搜索筛选 │
│ [搜索框] [知识点] [难度] │
├─────────────────────────────────────────────────────┤
│ 题目列表 │
│ ┌────────┬────────┬────────┬────────┬────┬────┐ │
│ │编号 │知识点 │题干 │难度 │来源│操作│ │
│ ├────────┼────────┼────────┼────────┼────┼────┤ │
│ │KP1001 │KP1001 │因式分解...│中等 │AI │查看│ │
│ └────────┴────────┴────────┴────────┴────┴────┘ │
│ 分页信息 │
└─────────────────────────────────────────────────────┘
# 1. 启动知识图谱服务
cd /Volumes/T9/code/math/apis/KnowledgeServic
docker compose up -d
# 2. 启动题库服务
cd /Volumes/T9/code/math/apis/QuestionBankService
docker compose up -d
# 3. 启动 Laravel 后台
cd /Volumes/T9/code/math/apis/FilamentAdmin
herd serve
URL: http://filament-admin.test/admin
在左侧导航菜单中,点击 "题库系统" → "题库管理"
Laravel 后台 (QuestionManagement.php)
↓ 发起 HTTP 请求
QuestionServiceApi.php
↓ 封装请求
题库服务 (localhost:5015)
↓ 查询数据库
PostgreSQL + pgvector
↓ 返回结果
Laravel 视图 (question-management.blade.php)
↓ 渲染页面
用户界面
// Laravel 调用
$service = app(QuestionServiceApi::class);
$response = $service->listQuestions(1, 25, [
'kp_code' => 'KP1001',
'search' => '因式分解'
]);
// 返回数据结构
{
"data": [
{
"id": 1,
"question_code": "KP1001-AI-ABC123",
"kp_code": "KP1001",
"stem": "因式分解题目内容...",
"answer": "(x+1)(x-1)",
"difficulty": 0.6,
"source": "ai::deepseek"
}
],
"meta": {
"page": 1,
"per_page": 25,
"total": 100,
"total_pages": 4
}
}
@forelse($questions as $question)
<tr>
<td>{{ $question['question_code'] }}</td>
<td>{{ $question['kp_code'] }}</td>
<td>{{ Str::limit($question['stem'], 80) }}</td>
<td>
<span class="badge bg-{{ $difficultyColor }}">
{{ $difficultyLabel }}
</span>
</td>
</tr>
@empty
<tr><td colspan="6">暂无数据</td></tr>
@endforelse
检查步骤:
# 1. 检查题库服务状态
curl http://localhost:5015/health
# 2. 检查 Laravel 错误日志
tail -f storage/logs/laravel.log
# 3. 检查 API 配置
cat .env | grep QUESTION_BANK_API_BASE
解决方案:
composer require livewire/livewirephp artisan view:clear && php artisan cache:clear解决方案:
# 清理所有缓存
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
# 重启开发服务器
herd restart
/Volumes/T9/code/math/apis/deployment_guide.md/Volumes/T9/code/math/apis/generate_100_questions.py/Volumes/T9/code/math/apis/enhanced_question_prompt.py/Volumes/T9/code/math/apis/deploy_and_manage.pyLaravel 后台的题库管理功能已完全实现,通过 API 方式与题库服务交互,不直接操作数据库。该方案具有以下特点:
可以立即使用!
创建日期:2025-11-15 版本:v1.0 状态:✅ 完成 维护者:Claude Code