/**
 * 菜单管理相关API
 */

import request from '@/utils/request'

/**
 * 获取菜单
 * @param parent_id
 */
export function getMenusChildren(parent_id = 0) {
  return request({
    url: `admin/systems/menus/children/${parent_id}`,
    method: 'get',
    params: { parent_id }
  })
}

/**
 * 添加菜单
 * @param params
 */
export function addMenu(params) {
  return request({
    url: 'admin/systems/menus',
    method: 'post',
    data: params
  })
}

/**
 * 修改菜单
 * @param id
 * @param params
 */
export function editMenu(id, params) {
  return request({
    url: `admin/systems/menus/${id}`,
    method: 'put',
    data: params
  })
}

/**
 * 删除菜单
 * @param id
 */
export function deleteMenu(id) {
  return request({
    url: `admin/systems/menus/${id}`,
    method: 'delete'
  })
}

// /admin/erp/user/menu
export function editHomeMenu(params) {
  return request({
    url: '/admin/erp/user/menu',
    method: 'post',
    data: params
  })
}

// /admin/erp/user/menu/{id}
export function deleteHomeMenu(id) {
  return request({
    url: `/admin/erp/user/menu/${id}`,
    method: 'delete'
  })
}

// 获取分页列表 /admin/erp/user/menu

export function getMenuList(params) {
  return request({
    url: '/admin/erp/user/menu',
    method: 'get',
    loaidng: false,
    params
  })
}
