Spaces:
Sleeping
Sleeping
File size: 1,677 Bytes
551658a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
from sqlalchemy.sql import text
from database import Base
class ProductMedia(Base):
__tablename__ = "product_media"
id = Column(Integer, primary_key=True, index=True, comment='主键 ID')
product_id = Column(Integer, ForeignKey('products.id'), nullable=True, index=True, comment='产品 ID(外键)')
product_number = Column(String(11), nullable=False, server_default="", index=True, comment='产品货号')
media_type = Column(String(20), nullable=False, server_default="image", index=True, comment='媒体类型:image, video')
r2_url = Column(String(500), nullable=False, server_default="", comment='媒体 URL(R2 原图 URL)')
thumbnail_r2_url = Column(String(500), nullable=False, server_default="", comment='缩略图 URL(R2 缩略图 URL)')
media_id = Column(String(32), nullable=False, server_default="", comment='素材ID')
media_alt = Column(String(200), nullable=False, server_default="", comment='ALT 标签/描述')
is_main = Column(Integer, nullable=False, server_default="0", comment='是否主图:0-否,1-是')
sort_order = Column(Integer, nullable=False, server_default="0", comment='排序顺序')
company_code = Column(String(50), nullable=False, server_default="", index=True, comment='公司编码,用于数据隔离')
created_at = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP'), comment='创建时间')
updated_at = Column(DateTime(timezone=True), nullable=False, server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), comment='更新时间')
|