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
+18 -1
View File
@@ -21,6 +21,17 @@ from repositories.advisor_visit_record import AdvisorVisitRecordRepo
from repositories.customer_relation import CustomerRelationRepo
def _todo_summary(todo) -> dict:
return {
"id": todo.id,
"todo_type": todo.todo_type,
"customer_id": todo.customer_id,
"priority": todo.priority,
"status": todo.status,
"due_at": todo.due_at.isoformat() if todo.due_at else None,
}
async def get_dashboard(db: AsyncSession, user: SysUser) -> dict:
relation_repo = CustomerRelationRepo(db)
todo_repo = AdvisorTodoRepo(db)
@@ -28,6 +39,9 @@ async def get_dashboard(db: AsyncSession, user: SysUser) -> dict:
visit_repo = AdvisorVisitRecordRepo(db)
pending = await todo_repo.count_by_advisor(advisor_id=user.id, status=TODO_STATUS_PENDING)
pending_items = await todo_repo.list_by_advisor(
advisor_id=user.id, status=TODO_STATUS_PENDING, limit=10, offset=0
)
total = await relation_repo.count_customer_rows(advisor_id=user.id)
signed = await relation_repo.count_customer_rows(
advisor_id=user.id, status=CUSTOMER_REL_STATUS_SIGNED
@@ -54,7 +68,10 @@ async def get_dashboard(db: AsyncSession, user: SysUser) -> dict:
unknown += cnt
return {
"todos": {"pending": pending},
"todos": {
"pending": pending,
"items": [_todo_summary(todo) for todo in pending_items],
},
"overview": {
"total_customers": total,
"signed_customers": signed,