50 lines
2.7 KiB
Python
50 lines
2.7 KiB
Python
from __future__ import annotations
|
|
|
|
from sqlalchemy import JSON, Float, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.constants import ProjectStatus
|
|
from app.models.base import TimestampMixin
|
|
from app.db import Base
|
|
|
|
|
|
class Project(TimestampMixin, Base):
|
|
"""项目管理:一条长视频 = 一个项目。"""
|
|
|
|
__tablename__ = "projects"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(200))
|
|
description: Mapped[str] = mapped_column(Text, default="")
|
|
genre: Mapped[str] = mapped_column(String(80), default="")
|
|
target_duration: Mapped[float] = mapped_column(Float, default=60.0)
|
|
aspect_ratio: Mapped[str] = mapped_column(String(16), default="16:9")
|
|
resolution: Mapped[str] = mapped_column(String(16), default="1080p")
|
|
fps: Mapped[int] = mapped_column(Integer, default=24)
|
|
|
|
# 导演阐述 / 全局风格与默认参数
|
|
style_guide: Mapped[str] = mapped_column(Text, default="")
|
|
global_negative_prompt: Mapped[str] = mapped_column(Text, default="")
|
|
default_provider: Mapped[str] = mapped_column(String(60), default="mock")
|
|
default_model: Mapped[str] = mapped_column(String(120), default="")
|
|
default_transition: Mapped[str] = mapped_column(String(30), default="cut")
|
|
settings_json: Mapped[dict] = mapped_column(JSON, default=dict)
|
|
|
|
status: Mapped[str] = mapped_column(String(30), default=ProjectStatus.DRAFT, index=True)
|
|
current_stage: Mapped[str] = mapped_column(String(40), default="create_project", index=True)
|
|
|
|
# 归属与操作人:名字冗余存一份,账号停用/改名后列表上仍能看出「当年是谁建的」
|
|
created_by_id: Mapped[int | None] = mapped_column(Integer, nullable=True, index=True)
|
|
created_by: Mapped[str] = mapped_column(String(80), default="", nullable=True)
|
|
updated_by_id: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
updated_by: Mapped[str] = mapped_column(String(80), default="", nullable=True)
|
|
|
|
characters: Mapped[list["Character"]] = relationship( # noqa: F821
|
|
back_populates="project", cascade="all, delete-orphan", lazy="selectin", order_by="Character.id")
|
|
scenes: Mapped[list["Scene"]] = relationship( # noqa: F821
|
|
back_populates="project", cascade="all, delete-orphan", lazy="selectin", order_by="Scene.id")
|
|
voices: Mapped[list["VoiceAsset"]] = relationship( # noqa: F821
|
|
back_populates="project", cascade="all, delete-orphan", lazy="selectin", order_by="VoiceAsset.id")
|
|
shots: Mapped[list["Shot"]] = relationship( # noqa: F821
|
|
back_populates="project", cascade="all, delete-orphan", lazy="selectin", order_by="Shot.order_index")
|