import { request } from "@umijs/max";

export interface MenuVO {
  id: number;
  name: string;
  permission: string;
  type: number;
  sort: number;
  parentId: number;
  path: string;
  icon: string;
  component: string;
  componentName?: string;
  status: number;
  visible: boolean;
  keepAlive: boolean;
  alwaysShow?: boolean;
  createTime: Date;
  children?: MenuVO[];
}

export interface MenuReqVO {
  name?: string;
  status?: 0 | 1;
}

// 查询菜单（精简）列表
export const getSimpleMenusList = () => {
  return request("/system/menu/simple-list", {
    method: "GET",
  });
};
// export const getSimpleMenusList = () => {
//   return request.get({ url: '/system/menu/simple-list' })
// }

// // 查询菜单列表

export const getMenuList = (params: MenuReqVO) => {
  return request("/system/menu/list", {
    method: "GET",
    params,
  });
};

// export const getMenuList = (params) => {
//   return request.get({ url: '/system/menu/list', params })
// }

// // 获取菜单详情

export const getMenu = (id: number) => {
  return request("/system/menu/get", {
    method: "GET",
    params: { id },
  });
};

// export const getMenu = (id: number) => {
//   return request.get({ url: '/system/menu/get?id=' + id })
// }

// // 新增菜单
export const createMenu = (data: MenuVO) => {
  return request("/system/menu/create", {
    method: "POST",
    data,
  });
};

// export const createMenu = (data: MenuVO) => {
//   return request.post({ url: '/system/menu/create', data })
// }

// // 修改菜单

export const updateMenu = (data: MenuVO) => {
  return request("/system/menu/update", {
    method: "PUT",
    data,
  });
};

// export const updateMenu = (data: MenuVO) => {
//   return request.put({ url: '/system/menu/update', data })
// }

// // 删除菜单

export const deleteMenu = (id: number) => {
  return request("/system/menu/delete", {
    method: "DELETE",
    params: { id },
  });
};

// export const deleteMenu = (id: number) => {
//   return request.delete({ url: '/system/menu/delete?id=' + id })
// }
