2026-08-24 13:03:04 +08:00
|
|
|
|
# server-core 记忆
|
|
|
|
|
|
|
|
|
|
|
|
## 角色
|
|
|
|
|
|
|
2026-08-24 14:24:45 +08:00
|
|
|
|
核心服务端(FastAPI,四层架构):身份/平台 API + 培训子应用(`app/training/`),对外 `opc.pinesound.cn`。
|
2026-08-24 13:03:04 +08:00
|
|
|
|
|
2026-08-24 14:24:45 +08:00
|
|
|
|
## 仓库(已迁 OPC-Hub)
|
|
|
|
|
|
|
|
|
|
|
|
- **`OPC-Hub/server-core`** @ `b90539a`(已从 `Pine/server-core` 转让,历史保留;`Pine/*` 旧仓库备份保留)。
|
|
|
|
|
|
- 本地 `code/server-core` = `OPC-Hub/server-core` 全新克隆(origin=infoepoch,infoepoch_lan 副远端)。
|
|
|
|
|
|
- 这是**四层架构**版(`app/api`(routers+schemas)、`app/infrastructure`、`app/services`、`app/domain`,async 仓储),非旧扁平版。
|
|
|
|
|
|
|
|
|
|
|
|
## 进度 / 现状(阶段0-1 已 port 至四层仓库)
|
2026-08-24 13:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
- 八端口 RBAC / select-identity / token 吊销 / require_port 完整(最成熟部分)。
|
|
|
|
|
|
- **阶段0-1 新增**:统一登录(手机/微信)+ 算力打通 + 契约。
|
|
|
|
|
|
|
|
|
|
|
|
### 本次改动文件(锚点)
|
|
|
|
|
|
|
|
|
|
|
|
| 文件 | 说明 | 锚点 |
|
|
|
|
|
|
|------|------|------|
|
|
|
|
|
|
| `app/config.py` | +算力/短信/微信配置 | `app/config.py` (COMPUTE_BASE_URL 等) |
|
|
|
|
|
|
| `app/models.py` | `User` 补 `wx_openid/phone` | `app/models.py` User |
|
|
|
|
|
|
| `app/repositories.py` | create 支持 wx/phone;+set_wx_openid/set_phone | `app/repositories.py` UserRepository |
|
|
|
|
|
|
| `app/services/sms.py` | 验证码(stub 默认) | 新增 |
|
|
|
|
|
|
| `app/services/wechat.py` | code2session(空 appid 直通) | 新增 |
|
|
|
|
|
|
| `app/services/compute_client.py` | new-api 客户端 | 新增 |
|
|
|
|
|
|
| `app/schemas/*.py` | 登录/算力 Pydantic | 新增 |
|
|
|
|
|
|
| `app/routers/auth.py` | +send-code/phone-login/wx-login/wx-phone | `app/routers/auth.py` |
|
|
|
|
|
|
| `app/routers/relay.py` | 上游改走 compute-engine(可回退 deepseek) | `app/routers/relay.py` |
|
|
|
|
|
|
| `app/routers/rbac_operator.py` | +compute/ping、compute/provision | `app/routers/rbac_operator.py` |
|
|
|
|
|
|
|
|
|
|
|
|
## 已实现(功能)
|
|
|
|
|
|
|
|
|
|
|
|
- 登录:`/auth/login`(密码)、`/auth/send-code`、`/auth/phone-login`、`/auth/wx-login`、`/auth/wx-phone`;多身份 `select-identity`。
|
|
|
|
|
|
- 算力:`/admin/compute/ping`、`/admin/compute/provision`;`compute_client` 封装 create_user/issue_pat/get_balance/get_month_usage/get_logs(路径为默认值,待实测核对)。
|
|
|
|
|
|
- 契约:`app/schemas/`,新端点带 `response_model`;OpenAPI 111 路径。
|
|
|
|
|
|
|
|
|
|
|
|
## 已知问题 / 待办
|
|
|
|
|
|
|
|
|
|
|
|
- 8 个 RBAC 既有失败测试(`test_rbac.py`/`test_operator_rbac.py`/`test_pine_universal.py`),**非本次引入**,待排查。
|
|
|
|
|
|
- 无 `app/training`、无 `data/opc.db`(阶段2 建)。
|
|
|
|
|
|
- compute_client 管理路由路径需按 compute-engine `controller/user.go` 实测。
|
|
|
|
|
|
- 单测:`tests/test_phone_wx_login.py`、`tests/test_compute_client.py`(均过)。
|
|
|
|
|
|
|
|
|
|
|
|
## 下一步(阶段 2)
|
|
|
|
|
|
|
|
|
|
|
|
courses/activities/bookings/tests 建表 + `/admin/*` 端点 + `/opc/*` 业务端点。
|