import AlarmMangExpAPI from '../../api/restApis/AlarmMangExpAPI'
import HelperUtil from '@/utils/HelperUtil'
import {ALARM_MANG_EXP_KEY, ALARM_MANG_EXP} from '../../utils/constantCollection'

// 静态方法
let staticMethods = {
  /**
   * @Description  : 创建
   * @author       : ls
   * @date         : 2020/5/2 14:17
   * @param        :
   * @return       :
   */
  addAlarmMangExp: function (template) {
    return AlarmMangExpAPI.addAlarmMangExp(template).then(result => {
      if (result.data.result) {
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  },
  /**
   * @Description  : 修改
   * @author       : ls
   * @date         : 2020/5/2 14:19
   * @param        :
   * @return       :
   */
  updateAlarmMangExp: function (template) {
    return AlarmMangExpAPI.putModifyAlarmMangExp(template).then(result => {
      if (result.data.result) {
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  },
  /**
   * @Description  : 删除
   * @author       : ls
   * @date         : 2020/5/2 14:19
   * @param        :
   * @return       :
   */
  delateAlarmMangExp: function (keyList) {
    return AlarmMangExpAPI.deleteDeleteAlarmMangExp(keyList).then(result => {
      if (result.data.result) {
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  },
  /**
   * @Description  : 导入
   * @author       : ls
   * @date         : 2020/7/7 11:57
   * @param        :
   * @return       :
   */
  uploadAlarmMangExp: function (fileFormData) {
    return AlarmMangExpAPI.postUploadAlarmMangExp(fileFormData).then(result => {
      if (result.data.result) {
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  },
  /**
   * @Description  : 导出
   * @author       : ls
   * @date         : 2020/7/7 15:56
   * @param        :
   * @return       :
   */
  downloadAlarmMangExpFile: function (conditionSet) {
    return AlarmMangExpAPI.putDownloadAlarmMangExp(conditionSet).then(result => {
      return HelperUtil.downFile(result, ALARM_MANG_EXP)
    })
  },
  /**
   * @Description  : 分页查询所有
   * @author       : ls
   * @date         : 2020/5/6 16:13
   * @param        :
   * @return       :
   */
  queryAlarmMangExpDataSplitNumber: function (beginItem, endItem, selectList) {
    return AlarmMangExpAPI.putAlarmMangExpQueryterms(beginItem, endItem, selectList).then(result => {
      if (result.data.result) {
        return HelperUtil.arrayToObject(result.data.returnValue, ALARM_MANG_EXP_KEY)
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  },
  /**
   * @Description  : 查询总数service
   * @author       : ls
   * @date         : 2020/5/6 16:12
   * @param        :
   * @return       :
   */
  queryAlarmMangExpTotalNumber: function (selectList) {
    return AlarmMangExpAPI.putAlarmMangExpListCounts(selectList).then(result => {
      if (result.data.result) {
        return result.data.returnValue
      } else {
        return HelperUtil.returnPromiseRejectObj(result)
      }
    })
  }
}

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