fix(knowledge): articles共享层语义对齐评审方案——entity_id=0系统共享(替代NULL) (entity-memory-partition 复核对齐)
This commit is contained in:
@@ -37,17 +37,17 @@ def list_articles(
|
||||
db: Session = Depends(get_db),
|
||||
entity_id: int = Depends(get_entity_id),
|
||||
):
|
||||
"""查询知识文章(本企业专属 ∪ 全局共享),可按关联页面或分类筛选
|
||||
"""查询知识文章(本企业专属 ∪ 系统共享),可按关联页面或分类筛选
|
||||
|
||||
隔离语义(2026-09-03 多租户分区):
|
||||
- entity_id IS NULL → 全局共享(CMA 系统教学知识,所有企业可见)
|
||||
- entity_id = 0 → 系统共享(CMA 教学知识,所有企业可见)
|
||||
- entity_id == 当前账套 → 企业专属(只本企业可见)
|
||||
- 其他企业的专属文章不可见
|
||||
"""
|
||||
q = db.query(KnowledgeArticle).filter(
|
||||
or_(
|
||||
KnowledgeArticle.entity_id == entity_id,
|
||||
KnowledgeArticle.entity_id.is_(None),
|
||||
KnowledgeArticle.entity_id == 0,
|
||||
)
|
||||
)
|
||||
if related_page:
|
||||
@@ -72,6 +72,6 @@ def get_article(
|
||||
)
|
||||
if not a:
|
||||
raise HTTPException(404, "文章不存在")
|
||||
if a.entity_id is not None and a.entity_id != entity_id:
|
||||
if a.entity_id != 0 and a.entity_id != entity_id:
|
||||
raise HTTPException(404, "文章不存在")
|
||||
return article_to_dict(a)
|
||||
|
||||
@@ -12,7 +12,7 @@ class KnowledgeArticle(Base):
|
||||
__tablename__ = "knowledge_articles"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, nullable=True, index=True, comment="企业ID: NULL=全局共享(系统教学), 有值=企业专属 (多租户隔离 2026-09-03)")
|
||||
entity_id = Column(Integer, default=0, nullable=False, index=True, comment="企业ID: 0=系统共享(CMA教学知识), >0=企业专属 (多租户隔离 2026-09-03)")
|
||||
title = Column(String(200), nullable=False, comment="文章标题")
|
||||
summary = Column(String(500), nullable=True, comment="一句话摘要")
|
||||
content = Column(Text, nullable=False, comment="文章正文(支持Markdown)")
|
||||
|
||||
Reference in New Issue
Block a user