feat(M02): 시스템 층 서버 길 · 층·도면 빈 틀 · 저장소(판·409·원자 쓰기) (PLAN 10-1)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148XFUpPfpiuTjxF1EK9c95
This commit is contained in:
2026-09-25 09:31:51 +09:00
co-authored by Claude Sonnet 5
parent 0b07251fc2
commit a0787a7859
8 changed files with 215 additions and 0 deletions
@@ -0,0 +1,48 @@
"""M02 마스터 템플릿 API — 시스템 층(계약 `6_계약.md` 서버 길 첫 묶음).
⚠ 권한은 등록하는 쪽(`main.py`)이 `system_admin_only` 로 붙임.
"""
from __future__ import annotations
from typing import Any
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from M02_MasterTemplete import M02_MasterTemplete_Store as store
router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete"])
class SaveBody(BaseModel):
판: str = ""
문서: Any
def _call(fn, *args):
try:
return fn(*args)
except store.StoreError as e:
raise HTTPException(status_code=e.status, detail=e.detail) from e
@router.get("/templates")
def get_templates() -> list[dict]:
return _call(store.list_all)
@router.get("/templates/{kind}/{name}")
def get_template(kind: str, name: str) -> dict:
return _call(store.read, kind, name)
@router.put("/templates/{kind}/{name}")
def put_template(kind: str, name: str, body: SaveBody) -> dict:
return _call(store.write, kind, name, body.판, body.문서)
@router.delete("/templates/{kind}/{name}")
def delete_template(kind: str, name: str, 판: str | None = None) -> dict:
_call(store.delete, kind, name, 판)
return {"ok": True}