feat:新增投顾agent和nl2sqlagent

This commit is contained in:
2026-09-13 16:19:24 +08:00
parent c80c6acac0
commit 163192bf55
122 changed files with 7488 additions and 362 deletions
+17
View File
@@ -1,6 +1,8 @@
"""风评域仓储:风评记录 + 客户画像(画像主键为 customer_id)。"""
from __future__ import annotations
from datetime import date
from sqlalchemy import select
from model.fin_customer_profile import FinCustomerProfile
@@ -11,6 +13,21 @@ from repositories.base import BaseRepository
class RiskAssessmentRepo(BaseRepository):
model = FinRiskAssessment
async def get_current_by_customer(self, customer_id: int) -> FinRiskAssessment | None:
"""Return the latest currently valid risk assessment for a customer."""
return await self.db.scalar(
select(FinRiskAssessment)
.where(
FinRiskAssessment.customer_id == customer_id,
FinRiskAssessment.valid_until >= date.today(),
)
.order_by(
FinRiskAssessment.assessment_date.desc(),
FinRiskAssessment.id.desc(),
)
.limit(1)
)
class CustomerProfileRepo(BaseRepository):
"""客户画像仓储。注意:主键是 customer_id 而非 id,不适用基类 get(pk)。"""