feat: 多租户隔离P2批1 — OKR域+kpi_values加entity_id列
- 模型: Objective/KR/ObjectiveKPI/KPIValue 加 entity_id - DB: 4表加列; kpi_values 1610条按kpi_id回填(1269酣客/341博海) - OKR域: 测试O删除重建; okr list/get/create + ontology trace/objectives 按token企业隔离(跨企业404) - KPIValue写入: data/bot_bridge/bot_kpis 创建时带entity_id - 验证: 酣客创建OKR博海不可见; 跨企业读404; pytest 451通过(expenses单跑37通过为既有排序flaky)
This commit is contained in:
@@ -99,6 +99,7 @@ class KPIValue(Base):
|
||||
"""KPI实际值"""
|
||||
__tablename__ = "kpi_values"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, default=None, comment="企业ID (P2多租户隔离 2026-08-23, 按kpi_id回填)")
|
||||
kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False)
|
||||
period = Column(String(20), nullable=False, comment="期间 2026-05")
|
||||
actual_value = Column(Float, nullable=True, comment="实际值")
|
||||
@@ -193,6 +194,7 @@ class Objective(Base):
|
||||
"""OKR目标"""
|
||||
__tablename__ = "objectives"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, default=1, comment="企业ID (P2多租户隔离 2026-08-23)")
|
||||
title = Column(String(200), nullable=False, comment="目标标题")
|
||||
description = Column(Text, nullable=True, comment="目标描述")
|
||||
dimension = Column(String(50), nullable=True, comment="关联维度: finance/customer/process/learning")
|
||||
@@ -703,6 +705,7 @@ class ObjectiveKPI(Base):
|
||||
"""KPI↔O支撑 — 目标由哪些KPI度量"""
|
||||
__tablename__ = "objective_kpi"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, default=1, comment="企业ID (P2多租户隔离 2026-08-23)")
|
||||
objective_id = Column(Integer, ForeignKey("objectives.id"), nullable=False, comment="OKR目标ID")
|
||||
kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=False, comment="KPI ID")
|
||||
weight = Column(Numeric(5, 2), default=1.00, comment="支撑权重")
|
||||
@@ -713,6 +716,7 @@ class KR(Base):
|
||||
"""关键结果KR — OKR完整化 (O→KR→KPI)"""
|
||||
__tablename__ = "krs"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
entity_id = Column(Integer, default=1, comment="企业ID (P2多租户隔离 2026-08-23)")
|
||||
objective_id = Column(Integer, ForeignKey("objectives.id"), nullable=False, comment="OKR目标ID")
|
||||
title = Column(String(200), nullable=False, comment="KR标题")
|
||||
metric_kpi_id = Column(Integer, ForeignKey("kpi_definitions.id"), nullable=True, comment="度量KPI ID")
|
||||
|
||||
Reference in New Issue
Block a user