初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,24 @@
|
||||
"""生成偏好数据访问(模型网关 §4.3)。
|
||||
|
||||
本地单用户单行,按 owner_scope 固定;无则由 service 层返回默认值。
|
||||
"""
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.governance import GenerationPreferences
|
||||
|
||||
|
||||
async def get_preferences(session: AsyncSession, owner_scope: str) -> GenerationPreferences | None:
|
||||
result = await session.execute(
|
||||
select(GenerationPreferences).where(GenerationPreferences.owner_scope == owner_scope)
|
||||
)
|
||||
return result.scalars().first()
|
||||
|
||||
|
||||
async def add_preferences(
|
||||
session: AsyncSession, prefs: GenerationPreferences
|
||||
) -> GenerationPreferences:
|
||||
session.add(prefs)
|
||||
await session.flush()
|
||||
return prefs
|
||||
Reference in new issue
Block a user