105 lines
3.0 KiB
TypeScript
105 lines
3.0 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type { PageResponse } from "@/shared/model";
|
|
|
|
import type {
|
|
ElaprApproverChangeRequestDto,
|
|
ElaprApproverInsertRequestDto,
|
|
ElaprPrgrsSttsMyDocSearchParams,
|
|
ElaprPrgrsSttsResponseDto,
|
|
ElaprPrgrsSttsSaveRequestDto,
|
|
ElaprPrgrsSttsService,
|
|
ElaprProcessRequestDto,
|
|
} from "../model/elapr-prgrs-stts-interface";
|
|
|
|
const BASE = ENDPOINT.AS_ELAPR_SERVICE.ELAPR_PRGRS_STTS;
|
|
|
|
async function findAllByDmndId(elaprDmndId?: string): Promise<ElaprPrgrsSttsResponseDto[]> {
|
|
const response = await client.get<ElaprPrgrsSttsResponseDto[]>(BASE, {
|
|
params: elaprDmndId ? { elaprDmndId } : undefined,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function findById(elaprPrgrsId: string): Promise<ElaprPrgrsSttsResponseDto> {
|
|
const response = await client.get<ElaprPrgrsSttsResponseDto>(`${BASE}/${elaprPrgrsId}`);
|
|
return response.data;
|
|
}
|
|
|
|
async function save(
|
|
requestDtos: ElaprPrgrsSttsSaveRequestDto[],
|
|
): Promise<ElaprPrgrsSttsResponseDto[]> {
|
|
const response = await client.post<ElaprPrgrsSttsResponseDto[]>(BASE, requestDtos);
|
|
return response.data;
|
|
}
|
|
|
|
async function process(
|
|
elaprPrgrsId: string,
|
|
body: ElaprProcessRequestDto,
|
|
): Promise<ElaprPrgrsSttsResponseDto> {
|
|
const response = await client.put<ElaprPrgrsSttsResponseDto>(
|
|
`${BASE}/${elaprPrgrsId}/process`,
|
|
body,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
async function processByDocNoAndAprvrUuid(
|
|
elaprDocNo: string,
|
|
aprvrUuid: string,
|
|
body: ElaprProcessRequestDto,
|
|
): Promise<ElaprPrgrsSttsResponseDto> {
|
|
const response = await client.put<ElaprPrgrsSttsResponseDto>(
|
|
`${BASE}/doc/${elaprDocNo}/aprvr/${aprvrUuid}/process`,
|
|
body,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
async function deletePrgrsStts(elaprPrgrsId: string): Promise<void> {
|
|
await client.delete(`${BASE}/${elaprPrgrsId}`);
|
|
}
|
|
|
|
async function updateApprover(
|
|
elaprPrgrsId: string,
|
|
body: ElaprApproverChangeRequestDto,
|
|
): Promise<ElaprPrgrsSttsResponseDto> {
|
|
const response = await client.put<ElaprPrgrsSttsResponseDto>(
|
|
`${BASE}/${elaprPrgrsId}/approver`,
|
|
body,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
async function insertApprover(
|
|
elaprDmndId: string,
|
|
body: ElaprApproverInsertRequestDto,
|
|
): Promise<ElaprPrgrsSttsResponseDto> {
|
|
const response = await client.post<ElaprPrgrsSttsResponseDto>(
|
|
`${BASE}/${elaprDmndId}/approver/insert`,
|
|
body,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
async function findMyElaperDocList(
|
|
params: ElaprPrgrsSttsMyDocSearchParams,
|
|
): Promise<PageResponse<ElaprPrgrsSttsResponseDto>> {
|
|
const response = await client.get<PageResponse<ElaprPrgrsSttsResponseDto>>(`${BASE}/my/doc`, {
|
|
params,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
export const elaprPrgrsSttsService = {
|
|
findAllByDmndId,
|
|
findById,
|
|
save,
|
|
process,
|
|
processByDocNoAndAprvrUuid,
|
|
delete: deletePrgrsStts,
|
|
updateApprover,
|
|
insertApprover,
|
|
findMyElaperDocList,
|
|
} satisfies ElaprPrgrsSttsService;
|