"""단가산출 로직 상세 읽기 · 셈 길(PLAN 717-1) — `/api/m02/logic-lib/…` · 로그인만(`main.py`). M01 상세 부품(`M01_MasterData_UI_Logic_Api.ts` · `Api_Fetch.ts` · `Logic_Note.ts`)이 길 앞머리만 `/m02/logic-lib` 로 바꿔 부름 — 길 · 몸 · 답 = M01 `/api/m01/…` 와 같음(M01 길 함수를 부름). 쓰기 없음 — `/calc` · `/text` 의 `row`(저장 안 한 고친 줄)는 메모리 사본에서만 셈(`Store._swap`). `/logics` · `/subs` · `/logic` · 원문은 `M02_MasterTemplete_Router_Combos.py` 에 있음. """ from __future__ import annotations from fastapi import APIRouter, HTTPException from M01_MasterData import M01_MasterData_Router as m01 router = APIRouter(prefix="/api/m02/logic-lib", tags=["M02 Logic Lib Read"]) #: `/rows` 로 줄을 내줄 요소 파일 앞머리 — 인력 · 재료 · 기계(고르기 표 · 품목 찾기) ROW_FILES = ("인력", "재료", "기계") #: `/table` 로 내줄 표 파일 앞머리 — 소요량 · 계수(설명 카드 원문 표) TABLE_FILES = ("소요량_", "계수_") @router.get("/logic/auto") def get_auto(key: str) -> dict: return m01.get_logic_auto(key) @router.get("/logic/flow") def get_flow(key: str, file: str = "") -> dict: """흐름 보기(읽기 · 변환해도 파일 안 바뀜).""" return m01.get_logic_flow(key, file) @router.get("/elements") def get_elements(group: str, q: str = "", limit: int = 50) -> dict: return m01.get_elements(group, q, min(limit, 200)) @router.get("/pick") def get_pick(kind: str, q: str = "", limit: int = 50) -> dict: return m01.get_pick(kind, q, min(limit, 200)) @router.get("/materials") def get_materials( sub: str, detail: str = "", spec: str = "", region: str = "", unit: str = "", limit: int = 50 ) -> dict: return m01.get_materials(sub, detail, spec, region, unit, min(limit, 200)) @router.get("/rows") def get_rows(file: str, page: int = 1, size: int = 50, q: str = "", sub: str = "") -> dict: if not file.startswith(ROW_FILES): raise HTTPException(status_code=403, detail="요소 파일(인력 · 재료 · 기계)만 읽음") return m01.get_rows(file, page, size, q, False, sub, "", "") @router.get("/table") def get_table(file: str, key: str) -> dict: if not file.startswith(TABLE_FILES): raise HTTPException(status_code=403, detail="소요량 · 계수 표만 읽음") return m01.get_table(file, key) @router.post("/calc") def post_calc(body: m01.CalcBody) -> dict: """M01 `/calc` 와 같음 — `row` = 저장 안 한 고친 줄(셈만 · 쓰기 없음).""" return m01.post_calc(body) @router.post("/text") def post_text(body: m01.CalcBody) -> dict: return m01.post_text(body)