import { ResPage, Menu } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 菜单管理模块
 */
// 获取分页列表
export const getMenuList = (params: Menu.ReqMenuParams) => {
  return http.get<ResPage<Menu.ResMenuList>>(PORT1 + `/system/menu/list`, params);
};

// 新增
export const addMenu = (params: Partial<Menu.ResMenuList>) => {
  return http.post(PORT1 + `/system/menu`, params);
};

// 编辑
export const editMenu = (params: Partial<Menu.ResMenuList>) => {
  return http.put(PORT1 + `/system/menu`, params);
};

// 删除
export const deleteMenu = (ids: string[]) => {
  return http.delete(PORT1 + `/system/menu/${ids.join(",")}`);
};

// 获取所有菜单
export const getAllTreeMenu = () => {
  return http.get<Menu.ResTreeMenu[]>(PORT1 + `/system/menu/treeselect`);
};

// 获取角色ID获取所有菜单权限
export const getCheckedKeysByRoleId = (roleId?: number) => {
  return http.get<Menu.ResRoleCheckedKeys>(PORT1 + `/system/menu/roleMenuTreeselect/${roleId || ""}`);
};
