21 lines
1.1 KiB
Python
21 lines
1.1 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey
|
|
from ..database import Base
|
|
|
|
|
|
class TemplateBlock(Base):
|
|
__tablename__ = "template_block"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
template_id = Column(Integer, ForeignKey("template.id", ondelete="CASCADE"), nullable=False, comment="所属模板")
|
|
block_id = Column(String(50), nullable=False, comment="唯一标识 block_001")
|
|
parent_block_id = Column(String(50), nullable=True, comment="父级 block_id")
|
|
block_type = Column(String(20), nullable=False, comment="title/heading/paragraph/table")
|
|
block_name = Column(String(200), nullable=True, comment="区域名称")
|
|
text_preview = Column(String(500), nullable=True, comment="文本预览")
|
|
level = Column(Integer, default=0, comment="0=文档标题 1=一级 2=二级")
|
|
sort_order = Column(Integer, default=0, comment="排序号")
|
|
table_rows = Column(Integer, nullable=True, comment="表格行数")
|
|
table_cols = Column(Integer, nullable=True, comment="表格列数")
|
|
created_at = Column(DateTime, default=datetime.now)
|