import { MenuOperationParams, MenuOperationApiResult } from '/@/api/system/model/menuModel';
import { ErrorMessageMode } from '/#/axios';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  Save = '/menu',
}

/**
 * @description: save menu api
 */
export function saveMenuApi(
  params: MenuOperationParams,
  update = false,
  mode: ErrorMessageMode = 'modal'
) {
  console.log(params);
  if (!update) {
    return defHttp.post<MenuOperationApiResult>(
      {
        url: Api.Save,
        params,
      },
      {
        errorMessageMode: mode,
      }
    );
  } else {
    return defHttp.put<MenuOperationApiResult>(
      { url: Api.Save, params },
      { errorMessageMode: mode }
    );
  }
}
