31 行
1.1 KiB
Python
31 行
1.1 KiB
Python
from __future__ import annotations
|
|
from sqlalchemy import Column, Integer, String, Text, ForeignKey, JSON
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class FaqCategory(Base):
|
|
__tablename__ = "faq_categories"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
category_id = Column(String(50), unique=True, nullable=False)
|
|
name = Column(String(100), nullable=False)
|
|
sort_order = Column(Integer, default=0)
|
|
|
|
questions = relationship("FaqQuestion", back_populates="category", cascade="all, delete-orphan", order_by="FaqQuestion.sort_order")
|
|
|
|
|
|
class FaqQuestion(Base):
|
|
__tablename__ = "faq_questions"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
category_id = Column(Integer, ForeignKey("faq_categories.id", ondelete="CASCADE"), nullable=False)
|
|
question_id = Column(String(50), unique=True, nullable=False)
|
|
question = Column(Text, nullable=False)
|
|
answer = Column(Text, nullable=False)
|
|
related_links = Column(JSON)
|
|
sort_order = Column(Integer, default=0)
|
|
|
|
category = relationship("FaqCategory", back_populates="questions")
|