feat:客户agent以及记忆模块功能开发
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
"""客户-投顾关系查询仓储。"""
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from model.customer_relation import CustomerRelation
|
||||
from repositories.base import BaseRepository
|
||||
|
||||
|
||||
class CustomerRelationRepo(BaseRepository):
|
||||
"""按客户 ID 隔离读取有效关系。"""
|
||||
|
||||
model = CustomerRelation
|
||||
|
||||
async def list_by_customer(self, customer_id: int) -> list[CustomerRelation]:
|
||||
"""返回指定客户尚未结束的关系。"""
|
||||
statement = (
|
||||
select(CustomerRelation)
|
||||
.where(
|
||||
CustomerRelation.customer_id == customer_id,
|
||||
CustomerRelation.status != "已结束",
|
||||
)
|
||||
.order_by(CustomerRelation.assign_time.desc(), CustomerRelation.id.desc())
|
||||
)
|
||||
return list((await self.db.scalars(statement)).all())
|
||||
|
||||
|
||||
__all__ = ["CustomerRelationRepo"]
|
||||
|
||||
Reference in New Issue
Block a user