From fa282b0c0430ded0d6ac2ca45b262d8fbe08447a Mon Sep 17 00:00:00 2001 From: Yesol Choi Date: Mon, 2 Jun 2025 15:57:35 +0900 Subject: [PATCH] =?UTF-8?q?func=20:=20=EC=A0=84=ED=91=9C=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20api=20=EC=83=9D=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/slipApi.ts | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/service/slipApi.ts diff --git a/src/service/slipApi.ts b/src/service/slipApi.ts new file mode 100644 index 0000000..e98e852 --- /dev/null +++ b/src/service/slipApi.ts @@ -0,0 +1,72 @@ +import axios from 'axios' +/** + * 임시전표 저장 + * @param {object} params + * @property {string} params.contNo -계약번호 + * @returns + */ +export async function saveTempSlip(params = {}) { + try { + const result = await axios.post(`/api/slip`, params) + return result.data + } catch (e) { + const serverError = e.response?.data; + + const message = typeof serverError?.body === 'string' + ? serverError.body + : 'Unknown error occurred'; + + const error = new Error(message); // ✅ 반드시 string만 넣기! 아니면 객체가 문자열로 나옴 + error.code = serverError?.code; + error.errTime = serverError?.errTime; + throw error; + } +} + +/** + * 임시전표 삭제 + * @property {string} params.contNo -계약번호 + * @returns + * @param contNo + */ +export async function deleteSlipDetail(contNo: string) { + try { + const result = await axios.delete(`/api/slip/${contNo}`) + return result.data + } catch (e) { + const serverError = e.response?.data; + + const message = typeof serverError?.body === 'string' + ? serverError.body + : 'Unknown error occurred'; + + const error = new Error(message); // ✅ 반드시 string만 넣기! 아니면 객체가 문자열로 나옴 + error.code = serverError?.code; + error.errTime = serverError?.errTime; + throw error; + } +} + +/** + * 전표 상세 조회 + * * @property {string} params.contNo -계약번호 + * * @returns + * * @param contNo + * */ +export async function getSlipDetail(contNo: string) { + try { + const result = await axios.get(`/api/slip/page/${contNo}`) + return result.data + } catch (e) { + const serverError = e.response?.data; + + const message = typeof serverError?.body === 'string' + ? serverError.body + : 'Unknown error occurred'; + + const error = new Error(message); // ✅ 반드시 string만 넣기! 아니면 객체가 문자열로 나옴 + error.code = serverError?.code; + error.errTime = serverError?.errTime; + throw error; + } +} \ No newline at end of file