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,