d195bef4d3
修复了用户创建时因数据库表名不匹配导致的 500 错误。 问题原因: 代码中使用了错误的数据库表名: - 使用 user_role 表,但实际表名是 roles - 使用 user_role_rela 表,但实际表名是 user_roles - 查询 user_role.id = 'user',但应该是 roles.code = 'user' 修改内容: 1. _role_ids_exist(): 修正表名从 user_role 到 roles,字段从 id 到 code 2. _replace_legacy_user_roles(): 修正表名从 user_role_rela 到 user_roles,并添加通过 role_code 查询 role_id 的逻辑 3. _assign_legacy_roles(): 修正默认角色查询从 user_role.id 到 roles.code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
API Service
FastAPI 后端服务,包含用户认证和 RBAC 权限控制。
核心能力
- JWT Access Token(默认 8 小时)
- Refresh Session(HttpOnly Cookie,默认 30 天,刷新轮换)
- RBAC(用户-角色-权限)
- 用户管理接口(需
user.manage)
本地开发
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r api/requirements.txt
python -m uvicorn api.app.main:app --reload --host 0.0.0.0 --port 8000
主要接口
GET /healthGET /api/v1/pingPOST /api/v1/auth/registerPOST /api/v1/auth/loginPOST /api/v1/auth/refreshPOST /api/v1/auth/logoutGET /api/v1/auth/meGET /api/v1/users