diff --git a/video-gen-api/app/api/v1/auth.py b/video-gen-api/app/api/v1/auth.py index ceed8027..0a16d8cb 100644 --- a/video-gen-api/app/api/v1/auth.py +++ b/video-gen-api/app/api/v1/auth.py @@ -267,24 +267,14 @@ async def get_me( name_map = await batch_get_team_name_map(db, [current_user.team_id]) team_name = name_map.get(current_user.team_id) - # 显式构造 dict 避免 Pydantic 扫描 ORM 对象触发懒加载 - user_dict = { - "id": current_user.id, - "username": current_user.username, - "email": current_user.email, - "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) + return UserOut.model_validate(current_user).model_copy( + update={ + "resource_capacity": resource_capacity, + "is_team_manager": is_team_manager, + "team_id": current_user.team_id, + "team_name": team_name, + } + ) @router.post(