"""管理会计OS — 知识库文章(P1-3 嵌入功能模块用) 与 KnowledgeSummary/KnowledgeEvent(AI摘要系统)不同,此表存储静态的CMA知识文章, 用于在功能模块右侧/底部嵌入展示。 """ from sqlalchemy import Column, Integer, String, Text, DateTime, func from app.database import Base class KnowledgeArticle(Base): """知识库文章""" __tablename__ = "knowledge_articles" id = Column(Integer, primary_key=True, index=True) title = Column(String(200), nullable=False, comment="文章标题") summary = Column(String(500), nullable=True, comment="一句话摘要") content = Column(Text, nullable=False, comment="文章正文(支持Markdown)") category = Column(String(50), nullable=True, comment="分类: term/formula/practice/faq") icon = Column(String(10), default="📖", comment="图标") related_page = Column(String(200), nullable=True, comment="关联页面路由,如 /maps/canvas/:id, /kpis, /budget, /deviations, /predict, /maps-review") sort_order = Column(Integer, default=0, comment="排序") created_at = Column(DateTime, server_default=func.now()) updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())