59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type { PageResponse } from "@/shared/model";
|
|
|
|
import {
|
|
ACNTG_SE_SAVE_MODE,
|
|
type AcntgSeMngPutRequestDto,
|
|
type AcntgSeMngResponseDto,
|
|
type AcntgSeMngSaveRequestDto,
|
|
type AcntgSeMngSearchDto,
|
|
type AcntgSeMngService,
|
|
type AcntgSeMngTreeDto,
|
|
} from "../model/acntg-interface";
|
|
|
|
const BASE = ENDPOINT.AS_COMMON_SERVICE.ACNTG_SE;
|
|
|
|
async function findAll(params: AcntgSeMngSearchDto): Promise<PageResponse<AcntgSeMngResponseDto>> {
|
|
const response = await client.get<PageResponse<AcntgSeMngResponseDto>>(BASE, { params });
|
|
return response.data;
|
|
}
|
|
|
|
async function findTree(): Promise<AcntgSeMngTreeDto[]> {
|
|
const response = await client.get<AcntgSeMngTreeDto[]>(`${BASE}/list/tree`);
|
|
return response.data;
|
|
}
|
|
|
|
async function findById(acntgSeCd: string): Promise<AcntgSeMngResponseDto> {
|
|
const response = await client.get<AcntgSeMngResponseDto>(`${BASE}/${acntgSeCd}`);
|
|
return response.data;
|
|
}
|
|
|
|
async function saveMulti(body: AcntgSeMngSaveRequestDto[]): Promise<AcntgSeMngResponseDto[]> {
|
|
const response = await client.post<AcntgSeMngResponseDto[]>(BASE, body);
|
|
return response.data;
|
|
}
|
|
|
|
async function update(acntgSeCd: string, body: AcntgSeMngPutRequestDto): Promise<string> {
|
|
const response = await client.put<string>(`${BASE}/${acntgSeCd}`, {
|
|
...body,
|
|
acntgSeCd,
|
|
mode: ACNTG_SE_SAVE_MODE.UPDATE,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function deleteAcntgSeCd(acntgSeCd: string): Promise<string> {
|
|
const response = await client.delete<string>(`${BASE}/${acntgSeCd}`);
|
|
return response.data;
|
|
}
|
|
|
|
export const acntgSeMngService = {
|
|
findAll,
|
|
findTree,
|
|
findById,
|
|
saveMulti,
|
|
update,
|
|
delete: deleteAcntgSeCd,
|
|
} satisfies AcntgSeMngService;
|