import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/roles',
    method: 'get',
    params: query
  })
}

export function fetchMenuList() {
  return request({
    url: '/menus',
    method: 'get'
  })
}

export function addRoleInfo(data) {
  return request({
    url: '/role/add',
    method: 'post',
    data: {
      roleName: data.roleName,
      description: data.description,
      menuArray: data.menuArray
    }
  })
}

export function updateRoleInfo(data) {
  return request({
    url: '/role/update/' + data.id,
    method: 'put',
    data: {
      roleName: data.roleName,
      description: data.description,
      menuArray: data.menuArray
    }
  })
}

export function getRoleInfo(id) {
  return request({
    url: '/role/' + id,
    method: 'get'
  })
}

export function deleteRoles(ids) {
  return request({
    url: '/role/delete',
    method: 'post',
    data: {
      idArray: ids
    }
  })
}

