From 8a99940554ff8815e44c538fa414522d3c00433e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Mon, 24 Aug 2026 12:01:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(groups):=20chat=5Fgroup=E6=94=B9=E5=A4=8D?= =?UTF-8?q?=E5=90=88=E4=B8=BB=E9=94=AE(channel,owner,room)=E2=80=94?= =?UTF-8?q?=E2=80=94=E5=A4=9A=E5=91=98=E5=B7=A5=E5=90=8C=E7=BE=A4=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E5=8E=BB=E9=87=8D(=E4=BA=91=E5=AE=A2=E5=BC=A0?= =?UTF-8?q?=E5=A3=AB=E8=93=9364=E7=BE=A4vs=E5=8E=9F42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原 room_id 单列 PK 把多员工同群合并成一行(末位覆盖owner),其他员工 群列表缺数据。改复合主键后同群每个员工各一行,对齐云客按员工查看。 重扫后 1590 行/865 去重群/张士蓓 64 群(与云客一致) Co-Authored-By: Claude --- yunke-server/app/db/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yunke-server/app/db/models.py b/yunke-server/app/db/models.py index a72e587..8d5a249 100644 --- a/yunke-server/app/db/models.py +++ b/yunke-server/app/db/models.py @@ -269,12 +269,12 @@ class ChatGroup(Base): __tablename__ = "chat_group" + # 复合主键(channel, owner, room):同一群在每个员工名下各一行(2026-08-24) + # 原按 room_id 单列 PK 会把多员工同群去重(云客张士蓓 64 群 vs 我们 42) room_id: Mapped[str] = mapped_column(String(128), primary_key=True) - channel: Mapped[str] = mapped_column(String(16), nullable=False) + channel: Mapped[str] = mapped_column(String(16), primary_key=True) + owner_account_id: Mapped[str] = mapped_column(String(128), primary_key=True) room_name: Mapped[str | None] = mapped_column(String(255), nullable=True) - owner_account_id: Mapped[str | None] = mapped_column( - String(128), nullable=True - ) # wechatId / uid of owning staff account owner_account_nickname: Mapped[str | None] = mapped_column( String(255), nullable=True )