- 종류 표 `Template_Layers.SHELF`(자리 · 머리 · 이름 · 번호 · 나무) — LIBRARY_KINDS · Labor_Ref PREFIX · TITLE · 내 기계 · 내 재료 자리 · 머리를 표에서 읽음
- 내 기계 번호 = 층 `_번호.json` 「내기계」 칸(Labor_Ref.issued · keep_issued 공개) · 지운 끝 번호 안 다시 씀 · 옛 `_다음.json` · 옛 `내기계.json` 옮김(_move · _read) 걷음(요구 899 — 옛 꼴 호환 없음)
- 내 기계 잠금 = store._LOCK 한 벌(RLock) — 번호 장부를 SK · SC 와 같이 쓰므로 두 잠금 순서 교착 막음
- 내 재료 = 한 파일 + 판(version) · 고칠 때 옛 판 409 {stale, 판, 까닭} · 목록 답에 판
- 내 재료 길 넷을 Labor_Router → MyMachine_Router(길 글자 그대로 · openapi 묶음 이름만 바뀜)
- 화면 Api 「종류 + 층」 한 함수 shelfPath(내 기계 · 내 재료 · 찾기 · 내 품목) · Material_Pick 은 내 재료 Api 부름 · 내 재료 화면이 판을 보내고 409 면 다시 읽음
- 시험: 854_1 번호 장부 · 내 기계 지운 끝 번호 · material_own 판 409 새 시험 · 826_2 ③(옛 파일 옮김 = 죽은 코드만 붙듦) 지움 · material_own 화면 소스 글자 시험 지움(글자 시험 규칙) · shelf golden 다시 뜸(고치기 전 답과 통째 대조 — 다름 = 내 재료 목록 판 칸 하나 · 뒤 차례 번호 밀림)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
/* =============================================================================
|
|
* M02_MyMaterial_Api.ts
|
|
* M02 내 재료(개인 자재 PM · PLAN 840-4) 서버 호출 — 개인 층만 · 서버 `M02_MyMachine_Router` 의 /layers/personal/materials
|
|
* (길 = 내 기계와 한 함수 `shelfPath` · 858 5-6)
|
|
* 목록(줄마다 쓰는 곳 + 파일 판) · 만들기 · 고치기(연 판 · 다르면 409 `StaleError`) · 지우기(쓰는 곳 있으면 409)
|
|
* · M01 재료 DB 와 같은 이름 · 규격 · 단위 = 409
|
|
* ========================================================================== */
|
|
|
|
import { call } from "./M02_MasterTemplete_Api_Fetch";
|
|
import { shelfPath } from "./M02_MyMachine_Api";
|
|
|
|
export interface MyMaterialUse {
|
|
종류: string;
|
|
키: string;
|
|
이름: string;
|
|
}
|
|
|
|
export interface MyMaterial {
|
|
키: string;
|
|
이름: string;
|
|
규격: string;
|
|
단위: string;
|
|
값: number | null;
|
|
쓰는곳?: MyMaterialUse[];
|
|
}
|
|
|
|
export type MyMaterialBody = Pick<MyMaterial, "이름" | "규격" | "단위" | "값">;
|
|
|
|
/** 목록 + 파일 판(고칠 때 보냄 · 858 5-6) */
|
|
export interface MyMaterialList {
|
|
줄: MyMaterial[];
|
|
판?: string;
|
|
}
|
|
|
|
const path = (owner: string | null, key = ""): string =>
|
|
shelfPath("materials", owner, key ? `/${encodeURIComponent(key)}` : "");
|
|
|
|
export const listMyMaterials = (owner: string | null): Promise<MyMaterialList> =>
|
|
call<MyMaterialList>(path(owner));
|
|
|
|
export const addMyMaterial = (owner: string | null, body: MyMaterialBody): Promise<MyMaterial> =>
|
|
call<MyMaterial>(path(owner), { method: "POST", body: JSON.stringify(body) });
|
|
|
|
export const editMyMaterial = (
|
|
owner: string | null,
|
|
key: string,
|
|
body: MyMaterialBody,
|
|
ver?: string,
|
|
): Promise<MyMaterial> =>
|
|
call<MyMaterial>(path(owner, key), {
|
|
method: "PUT",
|
|
body: JSON.stringify({ ...body, 판: ver ?? null }),
|
|
});
|
|
|
|
export const dropMyMaterial = (owner: string | null, key: string): Promise<unknown> =>
|
|
call(path(owner, key), { method: "DELETE" });
|