62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import {
|
|
LwpoCodeFormSchema,
|
|
type LwpoCodeService,
|
|
type LwpoCodeList,
|
|
type LwpoCodeDetail,
|
|
type LwpoCodeParams,
|
|
type LwpoCodeFormData,
|
|
} from "../model/lwpocode-interface";
|
|
|
|
export class LwpoCodeApiService implements LwpoCodeService {
|
|
public async getLwpoCodeList(params?: LwpoCodeParams): Promise<LwpoCodeList> {
|
|
const response = await client.get<LwpoCodeList>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}`,
|
|
{ params },
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async getUpCodeLwpoCodeList(upCd: string): Promise<LwpoCodeList> {
|
|
const response = await client.get<LwpoCodeList>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/up-cd/${upCd}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async LwpoCodeDetail(upCd: string, LwpoCd: string): Promise<LwpoCodeDetail> {
|
|
const response = await client.get<LwpoCodeDetail>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async createLwpoCode(data: LwpoCodeFormData): Promise<void> {
|
|
const validatedData = LwpoCodeFormSchema.parse(data);
|
|
const response = await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}`,
|
|
validatedData,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async updateLwpoCode(upCd: string, LwpoCd: string, data: LwpoCodeFormData): Promise<void> {
|
|
const validatedData = LwpoCodeFormSchema.parse(data);
|
|
const response = await client.put<void>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`,
|
|
validatedData,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async deleteLwpoCode(upCd: string, LwpoCd: string): Promise<void> {
|
|
await client.delete<void>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`,
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
export const lwpoCodeApi = new LwpoCodeApiService();
|