LocationAPI.js 1.61 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
import Axios from 'axios'

import {LOCATION_ADMQ,LOCATION_QUERY,LOCATION_UPLOAD,LOCATION_DOWNLOAD,REQUEST_CONFIG} from "../../utils/RequestUrls";

var staticMethods = {
  // 获取所有机房
  getLocationCollection: function(){
    return Axios.get(LOCATION_ADMQ);
  },

  // 添加机房
  postAddLocation: function (location) {
    return Axios.post(LOCATION_ADMQ,location,REQUEST_CONFIG);
  },

  // 删除机房
  deleteDeleteLocation: function (locationKeyList) {
    return Axios.delete(LOCATION_ADMQ,{
      data:locationKeyList,
      headers:{'Content-Type':'application/json','Encoding':'utf-8'}
    });
  },

  // 修改机房
  putModifyLocation: function (location) {
    return Axios.put(LOCATION_ADMQ,location,REQUEST_CONFIG);
  },

  // 条件查询机房
  putConditionQueryLocation: function (conditionSet) {
    return Axios.put(LOCATION_QUERY,conditionSet,REQUEST_CONFIG);
  },

  // 机房文件下载
  putDownloadLocation: function (conditionSet) {
    return Axios.put(LOCATION_DOWNLOAD,conditionSet,{
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    });
  },

  // 机房文件上传
  postUploadLocation: function (fileFormData) {
    return Axios.post(LOCATION_UPLOAD + '/1',fileFormData,{headers: {
        'Content-Type': 'multipart/form-data',
        'Accept': 'application/json'
      }});
  }

};

function LocationAPI (websocketService = null) {

  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}
// inject static methods
Object.assign(LocationAPI, staticMethods);
export default LocationAPI