import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/dmFoodCate',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/dmFoodCate',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/dmFoodCate',
    method: 'put',
    data
  })
}

export function getFoodCate(params) {
  return request({
    url: 'api/dmFoodCate',
    method: 'get',
    params
  })
}

export function getFoodCateTree(pid) {
  return request({
    url: 'api/dmFoodCate/lazy?pid=' + pid,
    method: 'get'
  })
}

export function getFoodCateSuperior(ids) {
  const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
  return request({
    url: 'api/dmFoodCate/superior',
    method: 'post',
    data
  })
}

export default { add, edit, del, getFoodCate, getFoodCateTree, getFoodCateSuperior }
