fix(module-key): make module keys standalone MD format with system_key relation

This commit is contained in:
Chris
2026-03-30 20:02:17 +08:00
parent c4266b7da5
commit 0cd863f9c2
7 changed files with 77 additions and 48 deletions

View File

@@ -29,10 +29,17 @@ def _resolve_module_id(db: Session, system_key: str, module_key: str | None) ->
if not system:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="system_not_found")
target_module_key = f"{system_key}.{module_key}" if module_key else f"{system_key}.__system__"
target_module_key = module_key if module_key else f"__system__{system_key}"
module = modules_repo.get_by_key(target_module_key)
if module and module.system_key != system_key:
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="module_system_mismatch")
if not module:
module = modules_repo.create(module_key=target_module_key, name=target_module_key, status="active")
module = modules_repo.create(
module_key=target_module_key,
system_key=system_key,
name=target_module_key,
status="active",
)
return module.id