import { request } from '@/api/_service'

const BASE = 'system_settings/menu_configuration/menu/'

function apiParams (method, data = {}) {
  return {
    method: `system_settings_menu_configuration_menu_${method}`,
    platform: 'background',
    ...data
  }
}

export function getMenuAll (data) {
  return request({
    url: BASE + 'all',
    method: 'get',
    params: apiParams('all', data)
  })
}

export function getMenuList (data) {
  return request({
    url: BASE + 'list',
    method: 'get',
    params: apiParams('list', data)
  })
}

export function createMenu (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('create', data)
  })
}

export function editMenu (data) {
  return request({
    url: BASE + 'edit',
    method: 'put',
    data: apiParams('edit', data)
  })
}

export function deleteMenu (data) {
  return request({
    url: BASE + 'delete',
    method: 'delete',
    data: apiParams('delete', data)
  })
}

export function updateMenuStatus (data) {
  return request({
    url: BASE + 'update_status',
    method: 'put',
    data: apiParams('update_status', data)
  })
}

export function sortMenu (data) {
  return request({
    url: BASE + 'sort',
    method: 'put',
    data: apiParams('sort', data)
  })
}
