import axiosApi from './AxiosApi.js'

const apiList = {
  page: {
    method: 'POST',
    url: `/dictionaryItem/page`
  },
  update: {
    method: 'PUT',
    url: `/dictionaryItem`
  },
  save: {
    method: 'POST',
    url: `/dictionaryItem`
  },
  delete: {
    method: 'DELETE',
    url: `/dictionaryItem`
  },
  list: {
    method: 'GET',
    url: `/dictionaryItem/codes`
  },
  preview: {
    method: 'POST',
    url: `/dictionaryItem/preview`
  },
  export: {
    method: 'POST',
    url: `/dictionaryItem/export`
  },
  import: {
    method: 'POST',
    url: `/dictionaryItem/import`
  }
}

export default {
  page (data) {
    return axiosApi({
      ...apiList.page,
      data
    })
  },
  save (data) {
    return axiosApi({
      ...apiList.save,
      data
    })
  },
  update (data) {
    return axiosApi({
      ...apiList.update,
      data
    })
  },
  delete (data) {
    return axiosApi({
      ...apiList.delete,
      data
    })
  },
  list (data) {
    return axiosApi({
      ...apiList.list,
      data
    })
  },
  preview (data) {
    return axiosApi({
      ...apiList.preview,
      data
    })
  },
  export (data) {
    return axiosApi({
      ...apiList.export,
      responseType: "blob",
      data
    })
  },
  import (data) {
    return axiosApi({
      ...apiList.import,
      data
    })
  }
}
