This commit is contained in:
2026-07-06 13:47:57 +08:00
parent e15197a437
commit 30c1ea970d
+14 -4
View File
@@ -267,14 +267,24 @@ 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)
return UserOut.model_validate(current_user).model_copy(
update={
# 显式构造 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,
"is_team_manager": is_team_manager,
"team_id": current_user.team_id,
"team_name": team_name,
"is_team_manager": is_team_manager,
}
)
return UserOut(**user_dict)
@router.post(