index.ts 625 Bytes
import { defHttp } from '@/utils/external/http/axios'
import { DictItem, UploadResponse } from './model'

enum Api {
  GET_DICT = '/dict_item',
  UPLOAD = '/oss/upload',
  DOWNLOAD = '/oss/download_file/'
}

export const getDictItemByCode = (value: string) => {
  return defHttp.post<DictItem[]>({
    url: `${Api.GET_DICT}/find`,
    params: {
      dictCode: value
    }
  })
}

export const upload = (file: FormData) => {
  return defHttp.post<UploadResponse>({
    url: Api.UPLOAD,
    params: file
  })
}

export const downloadFile = (fileName: string) => {
  return defHttp.get({ url: `${Api.DOWNLOAD}${fileName}` })
}