2026-07-23 15:04:16 +08:00
|
|
|
"""文案模板模型。"""
|
|
|
|
|
from sqlalchemy import Column, String, Text, SmallInteger, BigInteger, TIMESTAMP, func
|
|
|
|
|
from insurance.db.compat import db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PosterCopyTemplate(db.Model):
|
|
|
|
|
"""文案模板表。"""
|
|
|
|
|
__tablename__ = "poster_copy_templates"
|
|
|
|
|
|
|
|
|
|
id = Column(BigInteger, primary_key=True, autoincrement=True)
|
|
|
|
|
name = Column(String(100), nullable=False, comment="模板名称")
|
|
|
|
|
scenario_tag = Column(String(50), nullable=True, comment="场景标签")
|
|
|
|
|
content = Column(Text, nullable=False, comment="文案模板,含 {{变量}} 占位符")
|
|
|
|
|
variables = Column(Text, nullable=True, comment="变量列表及说明 JSON")
|
|
|
|
|
status = Column(SmallInteger, default=1, comment="1=启用, 0=停用")
|
|
|
|
|
created_at = Column(TIMESTAMP, server_default=func.now())
|
2026-07-31 14:10:24 +08:00
|
|
|
deleted_at = Column(TIMESTAMP, nullable=True, comment="软删除时间")
|
2026-07-23 15:04:16 +08:00
|
|
|
|
|
|
|
|
def to_dict(self):
|
|
|
|
|
import json
|
|
|
|
|
return {
|
|
|
|
|
"id": self.id,
|
|
|
|
|
"name": self.name,
|
|
|
|
|
"scenarioTag": self.scenario_tag,
|
|
|
|
|
"content": self.content,
|
|
|
|
|
"variables": json.loads(self.variables) if self.variables else [],
|
|
|
|
|
"status": self.status,
|
|
|
|
|
"createdAt": self.created_at.isoformat() if self.created_at else None,
|
2026-07-31 14:10:24 +08:00
|
|
|
"deletedAt": self.deleted_at.isoformat() if self.deleted_at else None,
|
2026-07-23 15:04:16 +08:00
|
|
|
}
|