97 lines
2.4 KiB
TypeScript
97 lines
2.4 KiB
TypeScript
import {
|
|
httpPostInterceptor,
|
|
httpGetInterceptor,
|
|
httpPutInterceptor,
|
|
httpDeleteInterceptor,
|
|
} from "./http-config/http-interceptor-service";
|
|
|
|
// Types
|
|
export interface MenuAction {
|
|
id: number;
|
|
menuId: number;
|
|
actionCode: string;
|
|
actionName: string;
|
|
description?: string;
|
|
pathUrl?: string;
|
|
httpMethod?: string;
|
|
position?: number;
|
|
isActive: boolean;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
}
|
|
|
|
export interface MenuActionCreateRequest {
|
|
menuId: number;
|
|
actionCode: string;
|
|
actionName: string;
|
|
description?: string;
|
|
pathUrl?: string;
|
|
httpMethod?: string;
|
|
position?: number;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
export interface MenuActionBatchCreateRequest {
|
|
menuId: number;
|
|
actionCodes: string[];
|
|
}
|
|
|
|
export interface MenuActionUpdateRequest {
|
|
menuId: number;
|
|
actionCode: string;
|
|
actionName: string;
|
|
description?: string;
|
|
pathUrl?: string;
|
|
httpMethod?: string;
|
|
position?: number;
|
|
isActive?: boolean;
|
|
}
|
|
|
|
// API Functions
|
|
export async function getMenuActions(params?: {
|
|
menuId?: number;
|
|
actionCode?: string;
|
|
page?: number;
|
|
limit?: number;
|
|
}) {
|
|
const queryParams = new URLSearchParams();
|
|
if (params?.menuId) queryParams.append("menu_id", params.menuId.toString());
|
|
if (params?.actionCode) queryParams.append("action_code", params.actionCode);
|
|
if (params?.page) queryParams.append("page", params.page.toString());
|
|
if (params?.limit) queryParams.append("limit", params.limit.toString());
|
|
|
|
const url = `menu-actions${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getMenuActionById(id: number) {
|
|
const url = `menu-actions/${id}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getMenuActionsByMenuId(menuId: number) {
|
|
const url = `menu-actions/menu/${menuId}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function createMenuAction(data: MenuActionCreateRequest) {
|
|
const url = "menu-actions";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function createMenuActionsBatch(data: MenuActionBatchCreateRequest) {
|
|
const url = "menu-actions/batch";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function updateMenuAction(id: number, data: MenuActionUpdateRequest) {
|
|
const url = `menu-actions/${id}`;
|
|
return httpPutInterceptor(url, data);
|
|
}
|
|
|
|
export async function deleteMenuAction(id: number) {
|
|
const url = `menu-actions/${id}`;
|
|
return httpDeleteInterceptor(url);
|
|
}
|
|
|