This commit is contained in:
2026-07-06 13:47:57 +08:00
parent e15197a437
commit 30c1ea970d
+18 -8
View File
@@ -267,14 +267,24 @@ async def get_me(
name_map = await batch_get_team_name_map(db, [current_user.team_id]) name_map = await batch_get_team_name_map(db, [current_user.team_id])
team_name = name_map.get(current_user.team_id) team_name = name_map.get(current_user.team_id)
return UserOut.model_validate(current_user).model_copy( # 显式构造 dict 避免 Pydantic 扫描 ORM 对象触发懒加载
update={ user_dict = {
"resource_capacity": resource_capacity, "id": current_user.id,
"is_team_manager": is_team_manager, "username": current_user.username,
"team_id": current_user.team_id, "email": current_user.email,
"team_name": team_name, "phone": current_user.phone,
} "avatar": current_user.avatar,
) "credits": current_user.credits,
"is_admin": current_user.is_admin,
"user_type": current_user.user_type,
"allowed_menus": current_user.allowed_menus,
"must_set_password": bool(current_user.user_type == "frontend" and not current_user.hashed_password),
"resource_capacity": resource_capacity,
"team_id": current_user.team_id,
"team_name": team_name,
"is_team_manager": is_team_manager,
}
return UserOut(**user_dict)
@router.post( @router.post(