- 도번 SD · 표번 SC + [종류][분류1][분류2] — 제목행(열 머리 세 층) 차례 · 없는 층 00 · 한 열 두 번호 같은 6자리 · 준 번호 유지(새 열 = 그 무리 다음 번호 · 지운 번호 비움)
- 구조물 = 꼴=수 열만(NO · 측점 · 비고 빠짐 · 브레인 판정)
- 집계표 [저장] — 새 열 두 파일 만들고 지운 열 두 파일 지움
- 새 산출근거 = 진짜 빈 시트(머리 줄 없음) · renumber() = 옛 번호 한 번 옮김 + 옛 기본 머리 줄 지움
- POST /structures/{열}/copy?from= · /basis/{열}/copy?from= — 내용만 · 번호 · 열은 받는 쪽
- GET /structures/numbers = {열 id: {도번, 표번}} · /basis/numbers 뺌
- 시험: test_m02_structure · test_spreadsheet_store 고쳐 씀
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EUypcnp5d1gU2aeKh9F2H7
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
"""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.post("/structures/{column}")
|
|
def post_structure(column: str) -> dict:
|
|
"""구조물 도면 새로 — 열 id 하나 · 도번 자동 · 빈 산출근거도 · 이미 있으면 409."""
|
|
return _call(store.create_structure, column)
|
|
|
|
|
|
@router.post("/structures/{column}/copy")
|
|
def post_structure_copy(column: str, source: str = Query(alias="from")) -> dict:
|
|
"""다른 열 구조물 도면 내용을 가져옴 — 도번 · 열은 받는 쪽 그대로."""
|
|
return _call(store.copy_structure, column, source)
|
|
|
|
|
|
@router.post("/basis/{column}/copy")
|
|
def post_basis_copy(column: str, source: str = Query(alias="from")) -> dict:
|
|
"""다른 열 산출근거 내용을 가져옴 — 표번 · 열은 받는 쪽 그대로."""
|
|
return _call(store.copy_basis, 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.문서)
|
|
|
|
|
|
@router.delete("/templates/{kind}/{name}")
|
|
def delete_template(kind: str, name: str, 판: str | None = None) -> dict:
|
|
_call(store.delete, kind, name, 판)
|
|
return {"ok": True}
|