| 123456789101112131415161718192021222324252627282930 |
- """附件元数据 CRUD"""
- from typing import Optional
- from sqlalchemy.orm import Session
- from app.models.business import Attachment
- def create_attachment(
- db: Session,
- *,
- file_name: str,
- object_key: str,
- url: str,
- size: int = 0,
- biz_type: Optional[str] = None,
- biz_id: Optional[str] = None,
- ) -> Attachment:
- row = Attachment(
- file_name=file_name,
- object_key=object_key,
- url=url,
- size=size,
- biz_type=biz_type,
- biz_id=biz_id,
- )
- db.add(row)
- db.commit()
- db.refresh(row)
- return row
|