类名 common/service/igs/PlotServer.js
import BaseServer from '../BaseServer'
import { Zondy } from '../../base'
import { FetchMethod } from '../../base/enum'

/**
 * 标绘服务
 * @class PlotServer
 * @moduleEx ServiceModule
 * @extends BaseServer
 * @param {Object} options 构造参数
 * @param {String} [options.url = 无] 服务基地址
 */
class PlotServer extends BaseServer {
  constructor(options) {
    super(options)
  }

  /**
   * 获取标绘图层列表
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  queryLayerList(options) {
    // 调用基类的查询信息方法
    return this._querySimpleInfo(options, function (url) {
      // 拼装返回基地址
      return `${url}/layers?f=json`
    })
  }

  /**
   * 更新标绘图层
   * @param options 查询参数
   * @param {String} [options.layerName] 图层名称,必填
   * @param {FeatureSet} [options.content] 图层内容,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {String} [options.layerId] 图层id
   */
  updateLayer(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      layerName: {
        type: 'String',
        required: true
      },
      content: {
        type: 'FeatureCollection',
        required: true
      },
      layerId: {
        type: 'String'
      }
    }

    // 设置为post请求
    options.method = FetchMethod.post

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/layers?f=json`
      }
    )
  }

  /**
   * 获取标绘图层
   * @param options 查询参数
   * @param {String} [options.layerId] 图层id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  getLayer(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      layerId: {
        type: 'String',
        required: true
      }
    }

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/layers/${options.layerId}?f=json`
      }
    )
  }

  /**
   * 删除标绘图层
   * @param options 查询参数
   * @param {String} [options.layerId] 图层id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  deleteLayer(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      layerId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 设置为delete方法
    options.method = FetchMethod.delete
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/layers/${options.layerId}?f=json`
      }
    )
  }

  /**
   * 查询态势推演脚本列表
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  queryAnimationScriptList(options) {
    // 调用基类的查询信息方法
    return this._querySimpleInfo(options, function (url) {
      // 拼装返回基地址
      return `${url}/scripts?f=json`
    })
  }

  /**
   * 更新态势推演脚本
   * @param options 查询参数
   * @param {String} [options.scriptName] 脚本名称,必填
   * @param {String} [options.content] 脚本内容,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   * @param {String} [options.scriptId] 脚本id
   */
  updateAnimationScript(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {}

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {
      scriptName: {
        type: 'String',
        required: true
      },
      content: {
        type: 'String',
        required: true
      },
      scriptId: {
        type: 'String'
      }
    }

    // 设置为post请求
    options.method = FetchMethod.post
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url) {
        return `${url}/scripts?f=json`
      }
    )
  }

  /**
   * 获取态势推演脚本
   * @param options 查询参数
   * @param {String} [options.scriptId] 脚本id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  getAnimationScript(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      scriptId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/scripts/${options.scriptId}?f=json`
      }
    )
  }

  /**
   * 删除态势推演脚本
   * @param options 查询参数
   * @param {String} [options.scriptId] 脚本id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  deleteAnimationScript(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      scriptId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 设置为delete方法
    options.method = FetchMethod.delete
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/scripts/${options.scriptId}?f=json`
      }
    )
  }

  /**
   * 获取标号库列表
   * @param options 查询参数
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  getSymbolLibList(options) {
    // 调用基类的查询信息方法
    return this._querySimpleInfo(options, function (url) {
      // 拼装返回基地址
      return `${url}/symbolLibs?f=json`
    })
  }

  /**
   * 获取标号库列表
   * @param options 查询参数
   * @param {String} [options.libId] 标号库id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  getSymbolLib(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      libId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/symbolLibs/${options.libId}?f=json`
      }
    )
  }

  /**
   * 获取标号
   * @param options 查询参数
   * @param {String} [options.libId] 标号库id,必填
   * @param {String} [options.symbolId] 标号id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  getSymbol(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      libId: {
        type: 'String'
      },
      symbolId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/symbolLibs/${options.libId}/symbols/${options.symbolId}?f=xml`
      }
    )
  }

  /**
   * 删除标号
   * @param options 查询参数
   * @param {String} [options.libId] 标号库id,必填
   * @param {String} [options.symbolId] 标号id,必填
   * @param {Function} [options.success] 查询成功回调函数,若使用Promise方式则不必填写
   * @param {Function} [options.failure] 查询失败回调函数,若使用Promise方式则不必填写
   */
  deleteSymbol(options) {
    // 设置PATH PARAMETERS校验
    const checkPathOpts = {
      libId: {
        type: 'String'
      },
      symbolId: {
        type: 'String'
      }
    }

    // 设置QUERY PARAMETERS校验
    const checkQueryOpts = {}

    // 使用delete方法
    options.method = FetchMethod.delete
    // 调用基类的查询信息方法
    return this._queryByParameters(
      options,
      checkPathOpts,
      checkQueryOpts,
      // 拼装返回基地址
      function (url, options) {
        return `${url}/symbolLibs/${options.libId}/symbols/${options.symbolId}?f=json`
      }
    )
  }
}

Zondy.Service.PlotServer = PlotServer
export default PlotServer
构造函数
成员变量
方法
事件