更新接口

This commit is contained in:
Ubuntu
2025-12-25 07:25:32 +00:00
parent 2e09716dd9
commit c735d60140
25 changed files with 6228 additions and 2077 deletions
+23 -2
View File
@@ -43,6 +43,15 @@ def _mask_api_key(key: str) -> str:
async def login(req: LoginRequest, db: AsyncSession = Depends(get_db)):
"""
用户/渠道/管理员/供应商登录
支持的角色:
- user: 租户用户
- channel: 渠道管理员
- billing_admin: 计费管理员
- operations_admin: 运营管理员
- admin: 管理员
- super_admin: 超级管理员
- provider: 供应商管理员
"""
# 根据角色查找用户
if req.role == "channel":
@@ -101,10 +110,22 @@ async def login(req: LoginRequest, db: AsyncSession = Depends(get_db)):
# 验证角色
user_role = user.role
if req.role == "admin" and user_role != "super_admin":
# 角色验证逻辑
valid_roles = {
"super_admin": ["super_admin"],
"admin": ["admin", "super_admin"],
"billing_admin": ["billing_admin", "admin", "super_admin"],
"operations_admin": ["operations_admin", "admin", "super_admin"],
"user": ["user"],
"provider": ["provider_admin"],
}
allowed_roles = valid_roles.get(req.role, [])
if user_role not in allowed_roles:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="权限不足"
detail=f"权限不足,当前角色: {user_role}"
)
# 创建JWT token