Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/adapters/db/models/support/response_template.py

30 lines
1.4 KiB
Python

from __future__ import annotations
from datetime import datetime
from sqlalchemy import DateTime, Integer, ForeignKey, String, Text, Boolean
from sqlalchemy.orm import Mapped, mapped_column, relationship
from adapters.db.session import Base
class SupportResponseTemplate(Base):
"""قالب‌های پاسخ اپراتور (سرور)"""
__tablename__ = "support_response_templates"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(100), nullable=False)
content: Mapped[str] = mapped_column(Text, nullable=False)
category_id: Mapped[int | None] = mapped_column(
Integer, ForeignKey("support_categories.id", ondelete="SET NULL"), nullable=True
)
is_global: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
created_by: Mapped[int] = mapped_column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
usage_count: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
updated_at: Mapped[datetime] = mapped_column(
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
)
creator = relationship("User", foreign_keys=[created_by])