77 lines
2.1 KiB
TypeScript
77 lines
2.1 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 filledParams = Object.fromEntries(
|
|
Object.entries(params).filter(([, value]) => value !== undefined && value !== ""),
|
|
);
|
|
const response = await client.get<NowDmgMtncGnsvyResponseDto[]>(
|
|
`${ENDPOINT.DC_SERVICE}/nowDmgMtncGnsvy`,
|
|
{ params: filledParams },
|
|
);
|
|
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;
|