文件版本管理-初步优化

This commit is contained in:
Cheng Zhou
2026-01-14 11:35:37 +08:00
parent ef1e67218c
commit f9ef5c109f
46 changed files with 4603 additions and 30 deletions
+36
View File
@@ -0,0 +1,36 @@
import uuid
from typing import Sequence
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.models.acknowledgement import Acknowledgement, AcknowledgementType
async def create(db: AsyncSession, ack: Acknowledgement, *, commit: bool = True) -> Acknowledgement:
db.add(ack)
if commit:
await db.commit()
await db.refresh(ack)
return ack
async def get_existing(
db: AsyncSession,
distribution_id: uuid.UUID,
user_id: uuid.UUID,
ack_type: AcknowledgementType,
) -> Acknowledgement | None:
result = await db.execute(
select(Acknowledgement).where(
Acknowledgement.distribution_id == distribution_id,
Acknowledgement.user_id == user_id,
Acknowledgement.ack_type == ack_type,
)
)
return result.scalar_one_or_none()
async def list_by_distribution(db: AsyncSession, distribution_id: uuid.UUID) -> Sequence[Acknowledgement]:
result = await db.execute(select(Acknowledgement).where(Acknowledgement.distribution_id == distribution_id))
return result.scalars().all()