import request from '@/utils/request'

// 获取所有的权限树
export function getPermissionTree() {
  return request({
    url: '/admin/rbac/permission/list',
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: '/admin/rbac/permission/save',
    method: 'post',
    data
  })
}

export function del(data) {
  return request({
    url: `/admin/rbac/permission/delete`,
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: '/admin/rbac/permission/update',
    method: 'post',
    data
  })
}

/**
 * 获取按钮权限列表查询
 *
 * @param queryParams
 */
export function queryPermissionList(queryParams) {
  return request({
    url: '/admin/rbac/permission/list',
    method: 'post',
    data: queryParams
  })
}

/**
 * 保存权限
 */
export function addPermission(data) {
  return request({
    url: '/admin/rbac/permission/save',
    method: 'post',
    data: data
  })
}

/**
 * 更新权限
 *
 * @param id
 * @param data
 */
export function updatePermission(data) {
  return request({
    url: '/admin/rbac/permission/update',
    method: 'post',
    data: data
  })
}

/**
 * 删除权限
 *
 * @param id
 */
export function deletePermission(id) {
  return request({
    url: '/admin/rbac/permission/delete',
    method: 'post',
    data: {
      id
    }
  })
}
