32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { ndmClient, type NdmKeyboardPageQuery, type NdmKeyboardResultVO, type NdmKeyboardUpdateVO, type PageParams, type PageResult } from '@/apis';
|
|
|
|
export const postNdmKeyboardPage = async (stationCode: string, pageQuery: PageParams<NdmKeyboardPageQuery>, signal?: AbortSignal) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.post<PageResult<NdmKeyboardResultVO>>(`${prefix}/api/ndm/ndmKeyboard/page`, pageQuery, { signal });
|
|
const [err, ndmKeyboardData] = resp;
|
|
if (err || !ndmKeyboardData) {
|
|
throw err;
|
|
}
|
|
return ndmKeyboardData;
|
|
};
|
|
|
|
export const getNdmKeyboardDetail = async (stationCode: string, id: string) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.get<NdmKeyboardResultVO>(`${prefix}/api/ndm/ndmKeyboard/detail`, { params: { id } });
|
|
const [err, ndmKeyboardData] = resp;
|
|
if (err || !ndmKeyboardData) {
|
|
throw err;
|
|
}
|
|
return ndmKeyboardData;
|
|
};
|
|
|
|
export const putNdmKeyboard = async (stationCode: string, updateVO: NdmKeyboardUpdateVO) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.put<NdmKeyboardResultVO>(`${prefix}/api/ndm/ndmKeyboard`, updateVO);
|
|
const [err, ndmKeyboard] = resp;
|
|
if (err || !ndmKeyboard) {
|
|
throw err;
|
|
}
|
|
return await getNdmKeyboardDetail(stationCode, ndmKeyboard.id ?? '');
|
|
};
|