feat:新增投顾agent和nl2sqlagent
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""基金业绩指标仓储。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
from model.fund_performance import FundPerformance
|
||||
from repositories.base import BaseRepository
|
||||
|
||||
|
||||
class FundPerformanceRepo(BaseRepository):
|
||||
model = FundPerformance
|
||||
|
||||
async def get_latest_for_product(self, product_id: int) -> FundPerformance | None:
|
||||
stmt = (
|
||||
select(FundPerformance)
|
||||
.where(FundPerformance.product_id == product_id)
|
||||
.order_by(
|
||||
FundPerformance.calc_date.desc(),
|
||||
FundPerformance.id.desc(),
|
||||
)
|
||||
.limit(1)
|
||||
)
|
||||
return (await self.db.scalars(stmt)).first()
|
||||
|
||||
async def list_for_product(self, product_id: int) -> list[FundPerformance]:
|
||||
stmt = (
|
||||
select(FundPerformance)
|
||||
.where(FundPerformance.product_id == product_id)
|
||||
.order_by(FundPerformance.period.asc())
|
||||
)
|
||||
return list((await self.db.scalars(stmt)).all())
|
||||
Reference in New Issue
Block a user