UX-3 附件上传删除功能
This commit is contained in:
@@ -57,3 +57,11 @@ async def list_attachments(
|
||||
async def get_attachment(db: AsyncSession, attachment_id: uuid.UUID) -> Attachment | None:
|
||||
result = await db.execute(select(Attachment).where(Attachment.id == attachment_id, Attachment.is_deleted.is_(False)))
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
|
||||
async def soft_delete_attachment(db: AsyncSession, attachment: Attachment) -> Attachment:
|
||||
attachment.is_deleted = True
|
||||
db.add(attachment)
|
||||
await db.commit()
|
||||
await db.refresh(attachment)
|
||||
return attachment
|
||||
|
||||
Reference in New Issue
Block a user