32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { ndmClient, type NdmCameraPageQuery, type NdmCameraResultVO, type NdmCameraUpdateVO, type PageParams, type PageResult } from '@/apis';
|
|
|
|
export const postNdmCameraPage = async (stationCode: string, pageQuery: PageParams<NdmCameraPageQuery>, signal?: AbortSignal) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.post<PageResult<NdmCameraResultVO>>(`${prefix}/api/ndm/ndmCamera/page`, pageQuery, { signal });
|
|
const [err, ndmCamera] = resp;
|
|
if (err || !ndmCamera) {
|
|
throw err;
|
|
}
|
|
return ndmCamera;
|
|
};
|
|
|
|
export const getNdmCameraDetail = async (stationCode: string, id: string) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.get<NdmCameraResultVO>(`${prefix}/api/ndm/ndmCamera/detail`, { params: { id } });
|
|
const [err, ndmCamera] = resp;
|
|
if (err || !ndmCamera) {
|
|
throw err;
|
|
}
|
|
return ndmCamera;
|
|
};
|
|
|
|
export const putNdmCamera = async (stationCode: string, updateVO: NdmCameraUpdateVO) => {
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const resp = await ndmClient.put<NdmCameraResultVO>(`${prefix}/api/ndm/ndmCamera`, updateVO);
|
|
const [err, ndmCamera] = resp;
|
|
if (err || !ndmCamera) {
|
|
throw err;
|
|
}
|
|
return await getNdmCameraDetail(stationCode, ndmCamera.id ?? '');
|
|
};
|