feat(api): GET /api/moments 朋友圈列表(desc分页+账号头部)
对齐云客员工聊天窗口朋友圈tab:帖子 create_time desc 分页 + wechat_account 头部(昵称/头像/别名);员工不存在不404(header全None 前端兜底)。头像提取抽共享 helper account_avatar 放 organization.py, accounts 列表与 moments 头部复用。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,16 @@ PageParam = Annotated[int, Query(ge=1)]
|
||||
PageSizeParam = Annotated[int, Query(ge=1, le=100)]
|
||||
|
||||
|
||||
def account_avatar(raw_json: dict | None) -> str | None:
|
||||
"""从账号原始记录提取头像 URL(共享 helper,2026-08-25)。
|
||||
|
||||
WeChat ``wxUser/list`` 记录携带 ``headImageUrl``;WA ``businessSalesList``
|
||||
记录无该键 → ``None``。accounts 列表与 moments 头部等多处复用,
|
||||
避免同键提取散落各处。
|
||||
"""
|
||||
return (raw_json or {}).get("headImageUrl")
|
||||
|
||||
|
||||
@router.get("/departments")
|
||||
async def list_departments(session: SessionDep) -> list[DepartmentOut]:
|
||||
"""Return every department ordered by ``path`` (nulls last).
|
||||
@@ -177,7 +187,7 @@ async def list_accounts(
|
||||
is_on_job=row.is_on_job,
|
||||
# 头像从原始记录提取(对齐云客员工聊天窗口左侧头像,2026-08-25):
|
||||
# WeChat headImageUrl;WA 原始记录无该键 -> None
|
||||
avatar=(row.raw_json or {}).get("headImageUrl"),
|
||||
avatar=account_avatar(row.raw_json),
|
||||
raw_json=row.raw_json,
|
||||
)
|
||||
for row in rows
|
||||
|
||||
Reference in New Issue
Block a user