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:
浅念
2026-08-25 15:57:53 +08:00
parent d3d7146887
commit 2837500bc0
5 changed files with 230 additions and 1 deletions
+52
View File
@@ -422,3 +422,55 @@ class SessionListOut(BaseModel):
channel: str
today_start: int
sessions: list[SessionOut]
# ---------------------------------------------------------------------------
# Moments (员工朋友圈)
# ---------------------------------------------------------------------------
class MomentsHeaderOut(BaseModel):
"""朋友圈头部 — 员工账号昵称/头像/别名(wechat_account 表)。
员工微信号不存在时三个字段全 ``None``(不 404,前端资料卡兜底)。
``avatar`` 从 ``raw_json.headImageUrl`` 提取(共享 helper
:func:`app.api.routers.organization.account_avatar`)。
"""
nickname: str | None = None
avatar: str | None = None
alias: str | None = None
class MomentsPostOut(BaseModel):
"""朋友圈帖子行(moments_post 表,``from_attributes`` 直读)。
结构化列驱动帖子卡片(正文/图片/点赞/评论);点赞/评论为上游 JSON
数组原样透传,由前端解析渲染。
"""
model_config = ConfigDict(from_attributes=True)
id: str
wechat_id: str
sns_id: str | None = None
author_name: str | None = None
author_wxid: str | None = None
author_avatar: str | None = None
content: str | None = None
type_raw: str | None = None
create_time: int | None = None # ms epoch
praise_json: list[dict[str, Any]] | None = None
comment_json: list[dict[str, Any]] | None = None
image_urls: list[str] | None = None
class MomentsListOut(BaseModel):
"""GET /api/moments 响应:账号头部 + 分页帖子(create_time desc)。"""
wechat_id: str
header: MomentsHeaderOut
total: int
page: int
page_size: int
items: list[MomentsPostOut]