feat: add class share drafts

This commit is contained in:
2026-07-31 16:07:18 +08:00
parent d8fde93b69
commit 429636f3e8
15 changed files with 410 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ from app.models.ai_config import ModelConfig, Prompt, SystemConfig
from app.models.base import Base
from app.models.chat import ChatMessage, ChatSession, TopicSession
from app.models.entitlement import EntitlementPlan, UserEntitlement, UserEntitlementLog
from app.models.growth import GrowthProfileRevision, TeacherHelpCard, TopicSummary, UserGrowthProfile
from app.models.growth import GrowthProfileRevision, ShareDraft, TeacherHelpCard, TopicSummary, UserGrowthProfile
from app.models.knowledge import (
HumanAttentionHistory,
HumanAttentionRecord,
@@ -55,6 +55,7 @@ __all__ = [
"Prompt",
"Role",
"SystemConfig",
"ShareDraft",
"TeacherHelpCard",
"User",
"UserEntitlement",

View File

@@ -82,3 +82,21 @@ class TeacherHelpCard(Base):
copied: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
copied_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
class ShareDraft(Base):
__tablename__ = "sys_share_draft"
__table_args__ = (
Index("ix_sys_share_draft_user_created", "user_id", "created_at"),
Index("ix_sys_share_draft_topic_created", "topic_session_id", "created_at"),
)
id: Mapped[int] = mapped_column(PRIMARY_KEY_TYPE, primary_key=True, autoincrement=True)
user_id: Mapped[int] = mapped_column(ForeignKey("sys_user.id"), index=True, nullable=False)
topic_session_id: Mapped[int] = mapped_column(ForeignKey("sys_topic_session.id"), index=True, nullable=False)
summary_id: Mapped[int | None] = mapped_column(BigInteger, index=True, nullable=True)
content: Mapped[str] = mapped_column(Text, nullable=False)
source: Mapped[str] = mapped_column(String(30), default="topic_summary", nullable=False)
copied: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
copied_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)