- resources/master_template/구조물집계표조합.json (그룹 · 판 · 비고 · 다음 · 줄) · 지금 열 51개로 처음 만듦(SS000001~SS000051) - 줄 칸: 키 · 열 · 종류 · 분류1~3 · 단위 · 일위대가 · 도번 · 면적번 · 재료번 · 바인딩 · 펼침 · 꼴=수 열만 - 새 열 = 새 SS 키 · 지운 열 = 줄 지움(키 다시 안 씀) · 고친 열 = 칸 갱신 · 새 프로젝트 복사에도 실림 - GET /api/m02/structure-combos · Api_Fetch fetchStructureCombos() - 시험: 견본 표로 키 유지 · 새 열 · 지운 열 · 글 열 제외 · 키대장 머리글과 안 겹침 · 프로젝트 복사 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EUypcnp5d1gU2aeKh9F2H7
82 lines
2.5 KiB
Python
82 lines
2.5 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.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.post("/material/{column}/copy")
|
|
def post_material_copy(column: str, source: str = Query(alias="from")) -> dict:
|
|
return _call(store.copy_from, "material", 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}
|