import { ndmClient, userClient, type ImportMsg, type NdmKeyboardPageQuery, type NdmKeyboardResultVO, type NdmKeyboardSaveVO, type NdmKeyboardUpdateVO, type PageParams, type PageResult, type Station, } from '@/apis'; import { unwrapResponse } from '@/utils'; export const pageKeyboardApi = async (pageQuery: PageParams, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard/page`; const resp = await client.post>(endpoint, pageQuery, { signal }); const data = unwrapResponse(resp); return data; }; export const detailKeyboardApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard/detail`; const resp = await client.get(endpoint, { params: { id }, signal }); const data = unwrapResponse(resp); return data; }; export const saveKeyboardApi = async (saveVO: NdmKeyboardSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard`; const resp = await client.post(endpoint, saveVO, { signal }); const data = unwrapResponse(resp); return data; }; export const updateKeyboardApi = async (updateVO: NdmKeyboardUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard`; const resp = await client.put(endpoint, updateVO, { signal }); const data = unwrapResponse(resp); return data; }; export const deleteKeyboardApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard`; const resp = await client.delete(endpoint, ids, { signal }); const data = unwrapResponse(resp); return data; }; export const exportKeyboardApi = async (pageQuery: PageParams, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard/defaultExportByTemplate`; const resp = await client.post(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal }); const data = unwrapResponse(resp); return data; }; export const importKeyboardApi = async (file: File, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmKeyboard/importReturnMsg`; const formData = new FormData(); formData.append('file', file); const resp = await client.post(endpoint, formData, { signal, upload: true }); const data = unwrapResponse(resp); return data; };