Files
frontend/apps/as/src/entities/dc/api/dc-service.ts
T

73 lines
1.9 KiB
TypeScript

import { client } from "@/shared/api";
import { ENDPOINT } from "@/shared/config";
import type {
ClsfSystmParamsDto,
ClsfSystmResponseDto,
DcService,
FileDownloadParamsDto,
FileParamsDto,
LvNowDmgMtncGnsvyResponseDto,
LvNowDmgMtncGnsvySearchDto,
NowDmgMtncGnsvyResponseDto,
NowDmgMtncGnsvySearchDto,
} from "../model/dc-interface";
async function getNowDmgMtncGnsvy(
params: NowDmgMtncGnsvySearchDto,
): Promise<NowDmgMtncGnsvyResponseDto[]> {
const response = await client.get<NowDmgMtncGnsvyResponseDto[]>(
`${ENDPOINT.DC_SERVICE}/nowDmgMtncGnsvy`,
{ params },
);
return response.data;
}
async function getLvNowDmgMtncGnsvy(
params: LvNowDmgMtncGnsvySearchDto,
): Promise<LvNowDmgMtncGnsvyResponseDto[]> {
const response = await client.get<LvNowDmgMtncGnsvyResponseDto[]>(
`${ENDPOINT.DC_SERVICE}/lvNowDmgMtncGnsvy`,
{ params },
);
return response.data;
}
async function getClsfSystm(params: ClsfSystmParamsDto): Promise<ClsfSystmResponseDto[]> {
const response = await client.get<ClsfSystmResponseDto[]>(`${ENDPOINT.DC_SERVICE}/clsf`, {
params,
});
return response.data;
}
async function getFile(params: FileParamsDto): Promise<unknown> {
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/file`, {
params,
});
return response.data;
}
async function getFilePrcs(fileSn: string): Promise<unknown> {
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/fileprcs`, {
params: { fileSn },
});
return response.data;
}
async function fileDownload(params: FileDownloadParamsDto): Promise<Blob> {
const response = await client.get<Blob>(`${ENDPOINT.DC_SERVICE}/fileDownload`, {
params,
responseType: "blob",
});
return response.data;
}
export const dcService = {
getNowDmgMtncGnsvy,
getLvNowDmgMtncGnsvy,
getClsfSystm,
getFile,
getFilePrcs,
fileDownload,
} satisfies DcService;