import ServiceSubnetAPI from "../../../api/restApis/BusinessAPI/ServiceSubnetAPI"
import HelperUtil from '../../../utils/HelperUtil'
import Vue from 'vue'

// 静态方法
let staticMethods = {
  //获取所有ServiceSubnet
  getAllEveSubnetCollection: function(mutator = () => {}){
    return ServiceSubnetAPI.getAllServiceSubnetCollection().then(result => {
      if (result.data.result) {
        return result.data.returnValue;
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  //添加
  addEveSubnet: function (eline) {
    return ServiceSubnetAPI.postServiceSubnetAdd(eline).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  //修改
  modifyEveSubnet: function (eline, serviceSubnetIDForupdate, serviceSubnetNameForUpdate) {
    return ServiceSubnetAPI.putServiceSubnetUpdate(eline,serviceSubnetIDForupdate, serviceSubnetNameForUpdate).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  //删除
  deleteEveSubnet: function (serviceSubnetKeyList) {
    return ServiceSubnetAPI.ServiceSubnetDelete(serviceSubnetKeyList).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  // 修改子网设备
  modifySubnetDevices: function (serviceSubnet) {
    return ServiceSubnetAPI.putModifySubnetDevices(serviceSubnet).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  }
}

function ServiceSubnetService (websocketService = null) {

  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}

// inject static methods
Object.assign(ServiceSubnetService, staticMethods);
export default ServiceSubnetService
