36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
"""ORM model for notification templates (通知模板管理).
|
|
|
|
Global / shared — no ``user_id`` scoping. ``created_by`` is audit-only.
|
|
All reads/writes are admin-gated at the router layer.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from sqlalchemy import Boolean, Integer, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from deerflow.persistence.base import Base
|
|
from deerflow.persistence.types import BeijingDateTime, PortableJSON
|
|
|
|
|
|
class NotificationTemplateRow(Base):
|
|
__tablename__ = "notification_templates"
|
|
__table_args__ = (UniqueConstraint("name", name="uq_notification_templates_name"),)
|
|
|
|
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(50))
|
|
title_template: Mapped[str] = mapped_column(String(120))
|
|
content_template: Mapped[str] = mapped_column(Text)
|
|
tags: Mapped[list] = mapped_column(PortableJSON(), default=list)
|
|
enabled: Mapped[bool] = mapped_column(Boolean, default=True, index=True)
|
|
version: Mapped[int] = mapped_column(Integer, default=1)
|
|
created_by: Mapped[str | None] = mapped_column(String(64))
|
|
created_at: Mapped[datetime] = mapped_column(BeijingDateTime(), default=lambda: datetime.now(UTC))
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
BeijingDateTime(),
|
|
default=lambda: datetime.now(UTC),
|
|
onupdate=lambda: datetime.now(UTC),
|
|
)
|