refactor(server): 按功能拆分 API 路由模块#362
Merged
huan-yp merged 7 commits intoOpenWSGR:mainfrom Mar 11, 2026
Merged
Conversation
将原 main.py 中的所有端点按功能拆分为独立路由模块: - routes/system.py: 系统管理 (/api/system/start|stop|status) - routes/task.py: 任务执行 (/api/task/start|stop|status) - routes/game.py: 游戏状态查询 (/api/game/context|acquisition, /api/expedition/status, /api/build/status) - routes/ops.py: 操作端点 (/api/expedition/check, /api/build/collect|start, /api/reward/collect, /api/cook, /api/repair/bath, /api/destroy) - routes/health.py: 健康检查 (/api/health) - serializers.py: 游戏对象序列化工具函数 main.py 精简为仅保留: 应用创建、生命周期管理、CORS、WebSocket 端点、路由注册。 新增 API 端点: - GET /api/game/context: 增强版,包含资源/舰队/远征/建造完整状态 - GET /api/expedition/status: 远征槽位状态查询 - GET /api/build/status: 建造队列状态查询 - POST /api/build/collect: 收取已完成建造 - POST /api/build/start: 开始建造 - POST /api/reward/collect: 收取任务奖励 - POST /api/cook: 食堂烹饪 - POST /api/repair/bath: 浴室修理 - POST /api/destroy: 解装/解体 - GET /api/health: 服务器健康检查 关联 issue: #360
for more information, see https://pre-commit.ci
huan-yp
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
将原 main.py 中的所有端点按功能拆分为独立路由模块,提高可维护性和问题定位效率。
文件结构
/api/system/*/api/task/*/api/game/*+/api/expedition/status+/api/build/status/api/health新增 API 端点
GET /api/game/context— 增强版,包含资源/舰队/远征/建造完整状态GET /api/expedition/status— 远征槽位状态查询GET /api/build/status— 建造队列状态查询POST /api/build/collect— 收取已完成建造POST /api/build/start— 开始建造POST /api/reward/collect— 收取任务奖励POST /api/cook— 食堂烹饪POST /api/repair/bath— 浴室修理POST /api/destroy— 解装/解体GET /api/health— 服务器健康检查测试
所有 16 个 REST 端点和 2 个 WebSocket 端点通过 FastAPI TestClient 验证:
关联 issue: #360