31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""客户关系中期记忆读取。"""
|
|
|
|
from repositories.customer_relation import CustomerRelationRepo
|
|
|
|
|
|
class CustomerRelationMemory:
|
|
"""读取客服上下文需要的客户-投顾关系。"""
|
|
|
|
def __init__(self, *, repository_factory=CustomerRelationRepo):
|
|
self.repository_factory = repository_factory
|
|
|
|
async def list(self, db, customer_id: int) -> list[dict]:
|
|
"""按客户 ID 返回有效关系。"""
|
|
relations = await self.repository_factory(db).list_by_customer(customer_id)
|
|
return [
|
|
{
|
|
"id": relation.id,
|
|
"customer_id": relation.customer_id,
|
|
"advisor_id": relation.advisor_id,
|
|
"assign_time": relation.assign_time,
|
|
"signed_time": relation.signed_time,
|
|
"end_time": relation.end_time,
|
|
"status": relation.status,
|
|
"reason": relation.reason,
|
|
}
|
|
for relation in relations
|
|
]
|
|
|
|
|
|
__all__ = ["CustomerRelationMemory"]
|