"""样板库模型(drawing_data 与目标站 254 套样本同构)。""" import datetime from sqlalchemy import DateTime, Integer, String, Text from sqlalchemy.orm import Mapped, mapped_column from huamenchuang.core.database import Base class WindoorTemplate(Base): """官方/企业窗型样板。drawing_data 为 shapeManager 序列化 JSON。""" __tablename__ = "windoor_templates" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) name: Mapped[str] = mapped_column(String(128), default="") drawing_data: Mapped[str] = mapped_column(Text) # 原样保留编辑器 JSON 字符串 pic_url: Mapped[str] = mapped_column(String(255), default="") catelog_id: Mapped[int] = mapped_column(Integer, default=0, index=True) note: Mapped[str] = mapped_column(String(255), default="") times: Mapped[int] = mapped_column(Integer, default=0) # 引用次数 # 尺寸限制(毫米),用于编辑器校验 low_width: Mapped[int] = mapped_column(Integer, default=0) high_width: Mapped[int] = mapped_column(Integer, default=0) low_height: Mapped[int] = mapped_column(Integer, default=0) high_height: Mapped[int] = mapped_column(Integer, default=0) is_default: Mapped[int] = mapped_column(Integer, default=1) # 1=官方样板 company_id: Mapped[int] = mapped_column(default=1, index=True) created_at: Mapped[datetime.datetime] = mapped_column(DateTime, default=datetime.datetime.utcnow) updated_at: Mapped[datetime.datetime] = mapped_column( DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow ) class WindoorCatelog(Base): """样板分类树(推拉门{平开,推拉,复古门,肯德基门,中式门窗,转角窗})。""" __tablename__ = "windoor_catelogs" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) name: Mapped[str] = mapped_column(String(64)) fid: Mapped[int] = mapped_column(Integer, default=0, index=True) note: Mapped[str] = mapped_column(String(255), default="") company_id: Mapped[int] = mapped_column(default=1, index=True)