| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- """
- AI视频生成ORM定义
- 定义AI视频生成系统的数据库表结构
- """
- from datetime import datetime
- from sqlalchemy import Column, Integer, String, Text, DateTime, Numeric, Boolean, Index
- from sqlalchemy.dialects.postgresql import JSONB
- from sqlalchemy.sql import func
- from app.database import Base
- class VideoModelConfig(Base):
- """视频模型参数配置表"""
- __tablename__ = "video_model_config"
- id = Column(Integer, primary_key=True, autoincrement=True)
- model_name = Column(String(100), unique=True, nullable=False, comment="模型名称")
- model_id = Column(String(100), nullable=False, comment="模型ID")
- model_type = Column(String(50), nullable=False, comment="模型类型:t2v/i2v/s2v")
- supported_params = Column(JSONB, nullable=False, comment="支持的参数配置JSON")
- is_active = Column(Boolean, default=True, comment="是否启用")
- created_at = Column(DateTime, server_default=func.now())
- updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
- __table_args__ = (
- Index('idx_video_model_config_type', 'model_type'),
- Index('idx_video_model_config_active', 'is_active'),
- {'schema': 'aigcspace', 'comment': '视频模型参数配置表'}
- )
- class AIVideo(Base):
- """AI视频生成记录表"""
- __tablename__ = "ai_video"
- id = Column(Integer, primary_key=True, autoincrement=True)
- user_id = Column(String(100), nullable=False, comment="用户ID")
- task_id = Column(String(100), unique=True, nullable=False, comment="百炼平台任务ID")
- model_name = Column(String(100), nullable=False, comment="使用的模型名称")
- video_type = Column(String(50), nullable=False, comment="视频类型:t2v/i2v/s2v")
- input_params = Column(JSONB, nullable=False, comment="输入参数JSON")
- prompt = Column(Text, comment="原始提示词")
- actual_prompt = Column(Text, comment="智能改写后的提示词")
- first_frame_url = Column(String(500), comment="首帧图片URL")
- last_frame_url = Column(String(500), comment="尾帧图片URL")
- audio_url = Column(String(500), comment="音频URL")
- video_url = Column(String(500), comment="输出视频OSS URL")
- video_duration = Column(Numeric(10, 2), comment="视频时长(秒)")
- resolution = Column(String(20), comment="视频分辨率")
- custom_name = Column(String(200), comment="用户自定义名称")
- status = Column(String(20), nullable=False, default='PENDING', comment="任务状态")
- error_message = Column(Text, comment="错误信息")
- bill = Column(Numeric(10, 4), default=0, comment="任务消耗费用")
-
- # 审核状态
- review_status = Column(String(20), default="pending", comment="审核状态")
- reviewed_by = Column(Integer, comment="审核人ID")
- reviewed_at = Column(DateTime, comment="审核时间")
- reject_reason = Column(String(500), comment="拒绝原因")
-
- submit_time = Column(DateTime, comment="任务提交时间")
- scheduled_time = Column(DateTime, comment="任务开始执行时间")
- end_time = Column(DateTime, comment="任务完成时间")
- created_at = Column(DateTime, server_default=func.now())
- updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
- __table_args__ = (
- Index('idx_ai_video_user_id', 'user_id'),
- Index('idx_ai_video_task_id', 'task_id'),
- Index('idx_ai_video_status', 'status'),
- Index('idx_ai_video_created_at', 'created_at'),
- Index('idx_ai_video_video_type', 'video_type'),
- {'schema': 'aigcspace', 'comment': 'AI视频生成记录表'}
- )
|