80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
import { client } from "@/shared/api";
|
|
import { ENDPOINT } from "@/shared/config";
|
|
import type {
|
|
MenuService,
|
|
Menu,
|
|
MenuItem,
|
|
MenuFormData,
|
|
MenuTemporarilyStoredData,
|
|
SiteMapFormData,
|
|
} from "../model/menu-interface";
|
|
|
|
export class MenuApiService implements MenuService {
|
|
async getMenuRoles(siteId: string): Promise<MenuItem[]> {
|
|
const response = await client.get<MenuItem[]>(
|
|
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async getMenuInfo(menuCd: number): Promise<Menu> {
|
|
const response = await client.get<Menu>(
|
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async createMenu(data: MenuFormData): Promise<void> {
|
|
const response = await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.MENUS}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async updateMenu(
|
|
menuCd: number,
|
|
data: Omit<MenuFormData, "siteId">,
|
|
): Promise<void> {
|
|
const response = await client.put<void>(
|
|
`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async deleteMenu(menuCd: number): Promise<void> {
|
|
await client.delete(`${ENDPOINT.CMS_SERVICE.MENUS}/${menuCd}`);
|
|
}
|
|
|
|
public async menuTemporaryStorage(
|
|
menuCd: number,
|
|
data: MenuFormData,
|
|
): Promise<void> {
|
|
const response = await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.MENU_TEMPORARY_STORAGE}/${menuCd}`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async getMenuTemporarilyStoredData(
|
|
menuCd: number,
|
|
): Promise<MenuTemporarilyStoredData[]> {
|
|
const response = await client.get<MenuTemporarilyStoredData[]>(
|
|
`${ENDPOINT.CMS_SERVICE.MENU_TEMPORARY_STORAGE}/menu/${menuCd}/user`,
|
|
);
|
|
return response.data;
|
|
}
|
|
|
|
public async publishSiteMap(data: SiteMapFormData["siteMap"]): Promise<void> {
|
|
const response = await client.post<void>(
|
|
`${ENDPOINT.CMS_SERVICE.MENUS}/sitemap/publish`,
|
|
data,
|
|
);
|
|
return response.data;
|
|
}
|
|
}
|
|
|
|
export const MenuApi = new MenuApiService();
|