From 4afa796ddc315a36d8ab4a90d27d0f5e8588f353 Mon Sep 17 00:00:00 2001 From: v6ole Date: Mon, 17 Aug 2026 09:43:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A4=9A=20primary=20=E7=BB=8F=E7=90=86=E6=97=B6=E9=A1=BF?= =?UTF-8?q?=E5=8F=B7=E8=BF=9E=E6=8E=A5=E6=98=BE=E7=A4=BA(=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=AD=97=E5=85=B8=E8=A6=86=E7=9B=96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mgr_map 由字典推导式改为按 customer_id 聚合 list,再用顿号连接 - 修复同一客户多个 primary 经理时,后写入覆盖先写入导致只显示一个名字 数据修复: 大化瑶族自治县公安局交通警察大队 移除韦柳柏的 primary 分配,唐晓静为唯一 primary Co-Authored-By: Claude --- backend/app/api/customers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/app/api/customers.py b/backend/app/api/customers.py index b95f1be..4722ceb 100644 --- a/backend/app/api/customers.py +++ b/backend/app/api/customers.py @@ -103,10 +103,14 @@ async def list_customers( select(CustomerAssignment.customer_id, User.name) .join(User, CustomerAssignment.manager_id == User.id) .where(CustomerAssignment.customer_id.in_([c.id for c in items]), CustomerAssignment.role == "primary") + .order_by(CustomerAssignment.customer_id) ) - mgr_map = {str(cid): name for cid, name in mgr_result.all()} + mgr_map: dict[str, list] = {} + for cid, name in mgr_result.all(): + mgr_map.setdefault(str(cid), []).append(name) for item in items: - item.primary_manager_name = mgr_map.get(str(item.id), None) + names = mgr_map.get(str(item.id), []) + item.primary_manager_name = "、".join(names) if names else None return CustomerListResponse( items=items,