feat: add tenant-scoped rule and permission management

This commit is contained in:
wren
2026-05-21 22:03:08 +08:00
parent a2c2bf1969
commit 1f1bccf3b3
193 changed files with 64463 additions and 1771 deletions
@@ -42,6 +42,9 @@ from fastapi_modules.fastapi_leaudit.models import (
LeauditDocument,
LeauditDocumentFile,
)
from fastapi_modules.fastapi_leaudit.services.impl.ruleTenantMaterializer import (
GetRuleTenantMaterializerSingleton,
)
log = logger
@@ -318,6 +321,24 @@ def leaudit_scan_stuck_documents_task(self) -> dict[str, Any]:
loop.close()
@celery_app.task(
bind=True,
name="leaudit.materialize_rule_tenants",
)
def leaudit_materialize_rule_tenants_task(self) -> dict[str, Any]:
"""周期补齐真实租户的规则私有副本。"""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
stats = loop.run_until_complete(
GetRuleTenantMaterializerSingleton().MaterializeAllEnabledTenants()
)
log.info("规则租户物化完成: %s", stats)
return {"status": "success", **stats}
finally:
loop.close()
# type_id → rules directory mapping (only fixed-mapping types)
# 行政许可 (type_id=2) has 9 sub-types, NOT mapped here —
# must come from document metadata (rules_file_path) or content classification.