feat: add resource library and real image workflow

This commit is contained in:
afei A
2026-03-29 00:24:29 +08:00
parent eeaff269eb
commit 04da401ab4
38 changed files with 3033 additions and 117 deletions

View File

@@ -0,0 +1,37 @@
"""Library resource file ORM model."""
from __future__ import annotations
from sqlalchemy import Enum, ForeignKey, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.domain.enums import LibraryFileRole
from app.infra.db.base import Base, TimestampMixin
class LibraryResourceFileORM(TimestampMixin, Base):
"""Persisted uploaded file metadata for a library resource."""
__tablename__ = "library_resource_files"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
resource_id: Mapped[int] = mapped_column(
ForeignKey("library_resources.id"),
nullable=False,
index=True,
)
file_role: Mapped[LibraryFileRole] = mapped_column(
Enum(LibraryFileRole, native_enum=False),
nullable=False,
index=True,
)
storage_key: Mapped[str] = mapped_column(String(500), nullable=False)
public_url: Mapped[str] = mapped_column(String(500), nullable=False)
bucket: Mapped[str] = mapped_column(String(255), nullable=False)
mime_type: Mapped[str] = mapped_column(String(255), nullable=False)
size_bytes: Mapped[int] = mapped_column(Integer, nullable=False)
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
width: Mapped[int | None] = mapped_column(Integer, nullable=True)
height: Mapped[int | None] = mapped_column(Integer, nullable=True)
resource = relationship("LibraryResourceORM", back_populates="files")