首页素材装修模块完成

This commit is contained in:
2026-06-30 17:06:45 +08:00
parent 37203cdbaf
commit b48979d4c4
32 changed files with 5279 additions and 15 deletions
+2
View File
@@ -30,6 +30,7 @@ from app.models.shot_replicate_segment import ShotReplicateSegment
from app.models.user_oauth import UserOAuth
from app.models.user_oauth_account import UserOAuthAccount
from app.models.user_oauth_app import UserOAuthApp
from app.models.home_material import HomeMaterialAsset, HomeMaterialCategory, HomeMaterialWatermark
__all__ = [
"Base", "TimestampMixin", "SoftDeleteMixin", "engine", "async_session",
@@ -44,4 +45,5 @@ __all__ = [
"ModuleGenerationProject", "ModuleGenerationStep",
"ShotReplicateTaskSet", "ShotReplicateSegment",
"UserOAuth", "UserOAuthAccount", "UserOAuthApp",
"HomeMaterialAsset", "HomeMaterialCategory", "HomeMaterialWatermark",
]
@@ -0,0 +1,9 @@
from app.models.home_material.asset import HomeMaterialAsset
from app.models.home_material.category import HomeMaterialCategory
from app.models.home_material.watermark import HomeMaterialWatermark
__all__ = [
"HomeMaterialAsset",
"HomeMaterialCategory",
"HomeMaterialWatermark",
]
@@ -0,0 +1,61 @@
from __future__ import annotations
from decimal import Decimal
from datetime import datetime
from sqlalchemy import BigInteger, Boolean, DateTime, Index, Integer, Numeric, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.enums.home_material import HomeMaterialAssetStatus, HomeMaterialMediaType
from app.models.base import Base, SoftDeleteMixin, TimestampMixin
class HomeMaterialAsset(Base, TimestampMixin, SoftDeleteMixin):
"""首页素材资产。"""
__tablename__ = "home_material_assets"
__table_args__ = (
Index("idx_home_material_assets_admin_list", "deleted_at", "category_id", "media_type", "status", "is_active", "sort_order", "created_at"),
Index("idx_home_material_assets_category_sort", "category_id", "sort_order", "created_at"),
Index("idx_home_material_assets_status", "status"),
)
id: Mapped[str] = mapped_column(String(32), primary_key=True)
category_id: Mapped[str] = mapped_column(String(32), nullable=False, index=True, comment="行业类别ID")
title: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True, comment="素材标题")
media_type: Mapped[str] = mapped_column(
String(16),
default=HomeMaterialMediaType.IMAGE.value,
server_default=HomeMaterialMediaType.IMAGE.value,
nullable=False,
index=True,
comment="素材类型:image图片,video视频",
)
original_url: Mapped[str] = mapped_column(Text, nullable=False, comment="原始素材URL")
original_storage_path: Mapped[str] = mapped_column(Text, nullable=False, comment="原始素材本地路径")
watermarked_url: Mapped[str | None] = mapped_column(Text, nullable=True, comment="水印素材URL")
watermarked_storage_path: Mapped[str | None] = mapped_column(Text, nullable=True, comment="水印素材本地路径")
cover_url: Mapped[str | None] = mapped_column(Text, nullable=True, comment="视频封面URL")
cover_storage_path: Mapped[str | None] = mapped_column(Text, nullable=True, comment="视频封面本地路径")
watermark_id: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="水印图片ID")
watermark_config_json: Mapped[str | None] = mapped_column(Text, nullable=True, comment="水印配置快照JSON")
status: Mapped[str] = mapped_column(
String(32),
default=HomeMaterialAssetStatus.DRAFT.value,
server_default=HomeMaterialAssetStatus.DRAFT.value,
nullable=False,
index=True,
comment="处理状态:draft/processing/success/failed",
)
error_message: Mapped[str | None] = mapped_column(Text, nullable=True, comment="处理失败原因")
width: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="素材宽度")
height: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="素材高度")
duration_seconds: Mapped[Decimal | None] = mapped_column(Numeric(10, 3), nullable=True, comment="视频时长,图片为空")
file_size_bytes: Mapped[int] = mapped_column(BigInteger, default=0, server_default="0", nullable=False, comment="原始文件大小")
watermarked_file_size_bytes: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="水印后文件大小")
is_active: Mapped[bool] = mapped_column(Boolean, default=True, server_default="true", nullable=False, index=True, comment="是否前台展示")
sort_order: Mapped[int] = mapped_column(Integer, default=0, server_default="0", nullable=False, index=True, comment="排序,越小越靠前")
processed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True, comment="处理完成时间")
created_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="创建管理员ID")
updated_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="更新管理员ID")
@@ -0,0 +1,40 @@
from __future__ import annotations
from sqlalchemy import Boolean, Index, Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, SoftDeleteMixin, TimestampMixin
class HomeMaterialCategory(Base, TimestampMixin, SoftDeleteMixin):
"""首页素材行业类别。"""
__tablename__ = "home_material_categories"
__table_args__ = (
Index("idx_home_material_categories_active_sort", "deleted_at", "is_active", "sort_order", "created_at"),
Index("idx_home_material_categories_key", "key"),
)
id: Mapped[str] = mapped_column(String(32), primary_key=True)
name: Mapped[str] = mapped_column(String(64), nullable=False, index=True, comment="行业名称")
key: Mapped[str] = mapped_column(String(64), nullable=False, comment="行业唯一标识,前台可按 key 查询")
description: Mapped[str | None] = mapped_column(String(255), nullable=True, comment="行业描述")
icon: Mapped[str | None] = mapped_column(String(64), nullable=True, comment="前端图标名称")
is_active: Mapped[bool] = mapped_column(
Boolean,
default=True,
server_default="true",
nullable=False,
index=True,
comment="是否启用",
)
sort_order: Mapped[int] = mapped_column(
Integer,
default=0,
server_default="0",
nullable=False,
index=True,
comment="排序,越小越靠前",
)
created_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="创建管理员ID")
updated_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="更新管理员ID")
@@ -0,0 +1,29 @@
from __future__ import annotations
from sqlalchemy import BigInteger, Boolean, Index, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, SoftDeleteMixin, TimestampMixin
class HomeMaterialWatermark(Base, TimestampMixin, SoftDeleteMixin):
"""首页素材水印图片库。"""
__tablename__ = "home_material_watermarks"
__table_args__ = (
Index("idx_home_material_watermarks_active", "deleted_at", "is_active", "created_at"),
Index("idx_home_material_watermarks_default", "deleted_at", "is_default"),
)
id: Mapped[str] = mapped_column(String(32), primary_key=True)
name: Mapped[str] = mapped_column(String(128), nullable=False, index=True, comment="水印名称")
file_url: Mapped[str] = mapped_column(Text, nullable=False, comment="水印图片URL")
storage_path: Mapped[str] = mapped_column(Text, nullable=False, comment="水印图片本地路径")
file_name: Mapped[str | None] = mapped_column(String(255), nullable=True, comment="原始文件名")
file_size_bytes: Mapped[int] = mapped_column(BigInteger, default=0, server_default="0", nullable=False, comment="文件大小")
width: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="水印图片宽度")
height: Mapped[int | None] = mapped_column(Integer, nullable=True, comment="水印图片高度")
is_default: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false", nullable=False, index=True, comment="是否默认水印")
is_active: Mapped[bool] = mapped_column(Boolean, default=True, server_default="true", nullable=False, index=True, comment="是否启用")
created_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="创建管理员ID")
updated_by: Mapped[str | None] = mapped_column(String(32), nullable=True, index=True, comment="更新管理员ID")