74 lines
2.0 KiB
TypeScript
74 lines
2.0 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}`,
|
|
);
|
|
}
|
|
|
|
public async codeRefreshAll(): Promise<void> {
|
|
await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.LWPO_CODE}/cache/refresh-all`,
|
|
);
|
|
}
|
|
}
|
|
|
|
export const LwpoCodeApi = new LwpoCodeApiService();
|