import { del, get, post, put } from '../../http'

/**
 * @description: 获取菜单树-用于新增，编辑时选择上级节点
 * @param {string}
 * @return {*}
 */
export const getPMenuTree = async () => {
  return await get<any>('/sysMenu/tree')
}

/**
 * @description: 保存菜单
 * @param {*} data
 * @return {*}
 */
export const saveMenuRule = async (data?: any) => {
  return await post<any>('/sysMenu', data)
}

/**
 * @description: 编辑菜单规则
 * @param {*} data
 * @return {*}
 */
export const updateMenuRule = async (data?: any) => {
  return await put('/sysMenu', data)
}

/**
 * @description: 删除菜单规则
 * @param {*} data
 * @return {*}
 */
export const deleteMenuRule = async (id: string) => {
  return await del(`/sysMenu/${id}`)
}

/**
 * @description: 获取菜单列表
 * @param {*} params
 * @return {*}
 */
export const getMenu = async (params?: any) => {
  return await get<any>('/sysMenu/list', params)
}

/**
 * @description: 修改订单状态
 * @param {*} data
 * @return {*}
 */
export const changeMenuStatus = async (data: {
  id: string
  status: number
}) => {
  return await post<any>('/sysMenu/changeStatus', data)
}

/**
 * @description: 获取授权的菜单树
 * @param {*} data
 * @return {*}
 */
export const getTreeForGrant = async () => {
  return await get<any>('/sysMenu/treeForGrant')
}
