import Vue from "vue";
import ServiceTypeAPI from "../../../api/restApis/BusinessAPI/ServiceTypeAPI";
import WebSocketService from "../WebSocketService";
import HelperUtil from '../../../utils/HelperUtil'
// 静态方法
let staticMethods = {
  // 获取所有ServiceType
  getAllServiceTypeCollection: function(mutator = () => {}){
    return ServiceTypeAPI.getServiceTypeCollection().then(result => {
      if (result.data.result) {
        return result.data.returnValue;
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  // 添加ServiceType
  addServiceType: function (serviceType) {
    return ServiceTypeAPI.postServiceTypeAdd(serviceType).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  // 删除ServiceType
  deleteServiceTypes: function (serviceTypeKeyList) {
    return ServiceTypeAPI.deleteServiceTypeDelete(serviceTypeKeyList).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  // 修改ServiceType
  modifyServiceType: function (serviceType) {
    return ServiceTypeAPI.putServiceTypeUpdate(serviceType).then(result => {
      if (result.data.result) {
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },

  // 条件查询ServiceType
  conditionQueryServiceType: function (conditionSet) {
    return ServiceTypeAPI.getServiceTypeByCondition(conditionSet).then(result => {
      if (result.data.result) {
        return result.data.returnValue;
      }else{
        return HelperUtil.returnPromiseRejectObj(result);
      }
    });
  },
};

function ServiceTypeService (websocketService = null) {
  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}
// inject static methods
Object.assign(ServiceTypeService, staticMethods);
export default ServiceTypeService
