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 {
|
|
CNSTP_SE_SAVE_MODE,
|
|
type CnstpSeMngPutRequestDto,
|
|
type CnstpSeMngResponseDto,
|
|
type CnstpSeMngSaveRequestDto,
|
|
type CnstpSeMngSearchDto,
|
|
type CnstpSeMngService,
|
|
type CnstpSeMngTreeDto,
|
|
} from "../model/cnstp-interface";
|
|
|
|
const BASE = ENDPOINT.AS_SERVICE.CNSTP_SE;
|
|
|
|
async function findAll(params: CnstpSeMngSearchDto): Promise<PageResponse<CnstpSeMngResponseDto>> {
|
|
const response = await client.get<PageResponse<CnstpSeMngResponseDto>>(BASE, { params });
|
|
return response.data;
|
|
}
|
|
|
|
async function findTree(): Promise<CnstpSeMngTreeDto[]> {
|
|
const response = await client.get<CnstpSeMngTreeDto[]>(`${BASE}/list/tree`);
|
|
return response.data;
|
|
}
|
|
|
|
async function findById(cnstpSeCd: string): Promise<CnstpSeMngResponseDto> {
|
|
const response = await client.get<CnstpSeMngResponseDto>(`${BASE}/${cnstpSeCd}`);
|
|
return response.data;
|
|
}
|
|
|
|
async function saveMulti(body: CnstpSeMngSaveRequestDto[]): Promise<CnstpSeMngResponseDto[]> {
|
|
const response = await client.post<CnstpSeMngResponseDto[]>(BASE, body);
|
|
return response.data;
|
|
}
|
|
|
|
async function update(cnstpSeCd: string, body: CnstpSeMngPutRequestDto): Promise<string> {
|
|
const response = await client.put<string>(`${BASE}/${cnstpSeCd}`, {
|
|
...body,
|
|
cnstpSeCd,
|
|
mode: CNSTP_SE_SAVE_MODE.UPDATE,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
async function deleteCnstpSeCd(cnstpSeCd: string): Promise<string> {
|
|
const response = await client.delete<string>(`${BASE}/${cnstpSeCd}`);
|
|
return response.data;
|
|
}
|
|
|
|
export const cnstpSeMngService = {
|
|
findAll,
|
|
findTree,
|
|
findById,
|
|
saveMulti,
|
|
update,
|
|
delete: deleteCnstpSeCd,
|
|
} satisfies CnstpSeMngService;
|