chore(853-2): 걸음 0 묶음 ② — 옛 시스템 전용 길 아홉(M02_MasterTemplete_Router) 걷음
- 길: GET · PUT · DELETE /api/m02/templates* · structure-combos · structures/numbers · POST structures/{열} · structures/{열}/copy · area/{열}/copy — 화면은 모두 /layers/{층}/… (Api_Fetch scoped) · TS · 다른 서버 모듈 · B0x 부르는 곳 0
- main.py 등록 두 줄 지움
- 시험 여섯(store · structure · structure_combo · combo_branch · empty_master · spreadsheet_store)은 같은 저장소를 살아 있는 /layers/system 길로 보게 옮김 — 도우미 helper_m02_system_client(시스템 관리자 세션) · 층 길과 다른 점만 고침(목록 = 양식 칸 · 지우기 = 판 대조 · 없는 종류 400 · 묶음 아닌 몸 422)
- 검증: /openapi.json 508 → 499(뜻한 9 만) · 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 245 통과
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
"""M02 마스터 템플릿 API — 시스템 층(계약 `6_계약.md` 서버 길 첫 묶음).
|
||||
|
||||
⚠ 권한은 등록하는 쪽(`main.py`)이 `system_admin_only` 로 붙임.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Query
|
||||
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("/structures/numbers")
|
||||
def get_structure_numbers() -> dict:
|
||||
return _call(store.structure_numbers)
|
||||
|
||||
|
||||
@router.get("/structure-combos")
|
||||
def get_structure_combos() -> dict:
|
||||
"""구조물집계표조합 — 구조물 열마다 줄 하나(키 SS · 제목행 · 번호 · 바인딩) · 읽기만."""
|
||||
return _call(store.read_combos)
|
||||
|
||||
|
||||
@router.post("/structures/{column}")
|
||||
def post_structure(column: str) -> dict:
|
||||
"""구조물 도면 새로 — 열 id 하나 · 도번 자동 · 빈 면적산출도 · 이미 있으면 409."""
|
||||
return _call(store.create_structure, column)
|
||||
|
||||
|
||||
# 복사 가져오기 — 다른 열(`from`) 내용을 받는 열로 · 번호 · 열은 받는 쪽 그대로
|
||||
@router.post("/structures/{column}/copy")
|
||||
def post_structure_copy(column: str, source: str = Query(alias="from")) -> dict:
|
||||
return _call(store.copy_from, "structure", column, source)
|
||||
|
||||
|
||||
@router.post("/area/{column}/copy")
|
||||
def post_area_copy(column: str, source: str = Query(alias="from")) -> dict:
|
||||
return _call(store.copy_from, "area", column, source)
|
||||
|
||||
|
||||
@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.문서, True) # 화면 [저장](26-7e)
|
||||
|
||||
|
||||
@router.delete("/templates/{kind}/{name}")
|
||||
def delete_template(kind: str, name: str, 판: str | None = None) -> dict:
|
||||
_call(store.delete, kind, name, 판)
|
||||
return {"ok": True}
|
||||
@@ -1,6 +1,6 @@
|
||||
"""M02 구조물 도면에 얹는 도각 길(`/structure-frame` · 56장) — B07 시스템 양식 도각을 그대로 다시 쓴다.
|
||||
|
||||
양식을 읽고 쓰는 길은 `M02_MasterTemplete_Router.py`(시스템 층)·`_Router_Layers.py`(층)가 맡는다.
|
||||
양식을 읽고 쓰는 길은 `_Router_Layers.py`(층 · 시스템 층 포함)가 맡는다.
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
⚠ 등록은 `main.py`(로그인만) · 층 권한은 `M02_Layer_Access`(양식 길 `Router_Layers` 와 한 벌 ·
|
||||
PLAN 27-1c) · `owner` = 회사 `{C}` · 개인 `{C}/{U}`(없으면 자기 층) · 회사 없음 = 409.
|
||||
옛 길(`/api/m02/structures/…` 등 · `M02_MasterTemplete_Router.py`)은 시스템 층 별칭으로 그대로.
|
||||
시스템 층도 이 길(`/layers/system/…`) — 옛 시스템 전용 길(`M02_MasterTemplete_Router.py`)은 걷음(894).
|
||||
회사 · 개인 층은 처음 부를 때 빈 뼈대를 만듦(`Items.ensure`).
|
||||
일위대가 갈라 내기(PLAN 27-2c): 새 조합은 그 층에(마스터 UA · 회사 UC · 개인 UP) · 층 쓰기 권한 ·
|
||||
첫 진입 뒤 구조물집계표가 이미 있어 같은 이름 새로 쓰기(판 없이)는 409 그대로.
|
||||
|
||||
Reference in New Issue
Block a user