|
| 1 | +import Qs from 'qs'; |
| 2 | + |
| 3 | +import { Zondy } from '../../common/Base'; |
| 4 | +import { CloudDiskService } from '../ServiceBase'; |
| 5 | + |
| 6 | +const AddPath = ''; |
| 7 | +const CatalogPath = '/catalog'; |
| 8 | +const CatalogTypePath = '/catalog/{type}?'; |
| 9 | +const ExecutePath = '/execute/{type}/{modelID}?'; |
| 10 | +const NodePath = '/node'; |
| 11 | +const NodeIdPath = '/node/{id}?'; |
| 12 | +const NodeRootPath = '/node/root'; |
| 13 | +const NodesPath = '/nodes'; |
| 14 | +const NodesIdPath = '/nodes/{nodeId}?'; |
| 15 | + |
| 16 | +/** |
| 17 | + * @class module:CloudDisk.GisCore.CalculateModelService |
| 18 | + * @description DataStore的云盘数据转换服务 |
| 19 | + * @see 该方法强依赖datastore |
| 20 | + * @author 基础平台-潘卓然 |
| 21 | + * @example |
| 22 | + * let service = new CalculateModelService({ domain: "http://192.168.199.53:9011"}); |
| 23 | + * service.setAuthorization('pk.sdfsedfsxseres'); |
| 24 | + * service.add({nodeId: 100}, (res) => {}, (error) => {}); |
| 25 | + * service.catalog({nodeId: 100}, (res) => {}, (error) => {}); |
| 26 | + */ |
| 27 | +export class CalculateModelService extends CloudDiskService { |
| 28 | + constructor(options) { |
| 29 | + super(options); |
| 30 | + /** |
| 31 | + * @member module:CloudDisk.CalculateModelService.prototype.serviceUrl |
| 32 | + * @description 服务地址 |
| 33 | + */ |
| 34 | + this.serviceUrl = '/clouddisk/rest/CalculateModel'; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @private 修正get/post需要的真正参数 |
| 39 | + */ |
| 40 | + fixOption(option) { |
| 41 | + this.option = {}; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @function module:CloudDisk.CalculateModelService.prototype.add |
| 46 | + * @description 空间数据元数据 |
| 47 | + * @param {Object} options 请求参数 |
| 48 | + * @param {Number} options.nodeId 节点id |
| 49 | + * @param {Object} options.model 目地目录 |
| 50 | + * @param {Number} options.model.id |
| 51 | + * @param {String} options.model.name |
| 52 | + * @param {String} options.model.version |
| 53 | + * @param {String} options.model.desp |
| 54 | + * @param {String} options.model.img |
| 55 | + * @param {String} options.model.modelType |
| 56 | + * @param {String} options.model.modelId |
| 57 | + * @param {Function} onSuccess 成功回调 |
| 58 | + * @param {Function} onError 失败回调 |
| 59 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel |
| 60 | + * { |
| 61 | + "nodeId": 3131, |
| 62 | + "id": 0, |
| 63 | + "name": "string", |
| 64 | + "version": "string", |
| 65 | + "desp": "string", |
| 66 | + "img": "string", |
| 67 | + "modelType": "string", |
| 68 | + "modelId": "string" |
| 69 | + } |
| 70 | + */ |
| 71 | + add(options, onSuccess, onError) { |
| 72 | + let { serviceUrl } = this; |
| 73 | + let baseurl = this.getBaseUrl(); |
| 74 | + let url = `${baseurl}${serviceUrl}${AddPath}?nodeId=${options.nodeId}`; |
| 75 | + delete options.nodeId; |
| 76 | + this.post(url, options, onSuccess, onError); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * @function module:CloudDisk.CalculateModelService.prototype.catalog |
| 81 | + * @description 空间数据元数据 |
| 82 | + * @param {Object} options 请求参数 |
| 83 | + * @param {Number} options.nodeId 节点id |
| 84 | + * @param {String} options.keyword 检索关键词 |
| 85 | + * @param {Function} onSuccess 成功回调 |
| 86 | + * @param {Function} onError 失败回调 |
| 87 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/catalog |
| 88 | + */ |
| 89 | + catalog(options, onSuccess, onError) { |
| 90 | + let { serviceUrl } = this; |
| 91 | + serviceUrl += CatalogPath; |
| 92 | + let url = this.getFullUrl(serviceUrl, options); |
| 93 | + this.get(url, onSuccess, onError); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * @function module:CloudDisk.CalculateModelService.prototype.catalogtype |
| 98 | + * @description 空间数据元数据 |
| 99 | + * @param {Object} options 请求参数 |
| 100 | + * @param {String} options.type 模型类型eg: igs 、bigdata |
| 101 | + * @param {String} options.modelID 模型id |
| 102 | + * @param {String} options.keyWords 模型功能类型 |
| 103 | + * @param {String} options.keys 模型检索关键词 |
| 104 | + * @param {Function} onSuccess 成功回调 |
| 105 | + * @param {Function} onError 失败回调 |
| 106 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/catalog/{type} |
| 107 | + */ |
| 108 | + catalogtype(options, onSuccess, onError) { |
| 109 | + const { type } = options; |
| 110 | + let { serviceUrl } = this; |
| 111 | + let baseurl = this.getBaseUrl(); |
| 112 | + let url = `${baseurl}${serviceUrl}${CatalogTypePath}`; |
| 113 | + url = url.replace('{type}', type); |
| 114 | + delete options.type; |
| 115 | + url = url + Qs.stringify(options); |
| 116 | + this.get(url, onSuccess, onError); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * @function module:CloudDisk.CalculateModelService.prototype.execute |
| 121 | + * @description 空间数据元数据 |
| 122 | + * @param {Object} options 请求参数 |
| 123 | + * @param {Object} options.type 模型类型 |
| 124 | + * @param {Object} options.modelID 模型id |
| 125 | + * @param {Function} onSuccess 成功回调 |
| 126 | + * @param {Function} onError 失败回调 |
| 127 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/execute/{type}/{modelID} |
| 128 | + */ |
| 129 | + execute(options, onSuccess, onError) { |
| 130 | + const { serviceUrl } = this; |
| 131 | + const { type, modelID } = options; |
| 132 | + let baseurl = this.getBaseUrl(); |
| 133 | + |
| 134 | + let url = `${baseurl}${serviceUrl}${ExecutePath}`; |
| 135 | + url = url.replace('{type}', type); |
| 136 | + url = url.replace('{modelID}', modelID); |
| 137 | + |
| 138 | + this.post(url, undefined, onSuccess, onError); |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * @function module:CloudDisk.CalculateModelService.prototype.node |
| 143 | + * @description 空间数据元数据 Parameter-Content-Type application/json |
| 144 | + * @param {Object} treeNode 请求参数 |
| 145 | + * @param {Function} onSuccess 成功回调 |
| 146 | + * @param {Function} onError 失败回调 |
| 147 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/node |
| 148 | + * { |
| 149 | + "id": 0, |
| 150 | + "name": "string", |
| 151 | + "pid": 0, |
| 152 | + "type": 0, |
| 153 | + "desp": "string", |
| 154 | + "nodeSelected": true, |
| 155 | + "nodeExpand": true, |
| 156 | + "sortId": 0, |
| 157 | + "nodeIco": "string", |
| 158 | + "year": "string", |
| 159 | + "ownerType": 0, |
| 160 | + "ownerId": "string", |
| 161 | + "applicationId": 0, |
| 162 | + "children": [ |
| 163 | + null |
| 164 | + ] |
| 165 | + } |
| 166 | + */ |
| 167 | + node(options, onSuccess, onError) { |
| 168 | + const { serviceUrl } = this; |
| 169 | + let baseurl = this.getBaseUrl(); |
| 170 | + let url = `${baseurl}${serviceUrl}${NodePath}`; |
| 171 | + this.post(url, options, onSuccess, onError); |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * @function module:CloudDisk.CalculateModelService.prototype.nodeid |
| 176 | + * @description 空间数据元数据 |
| 177 | + * @param {Object} options 请求参数 |
| 178 | + * @param {String} options.id 节点id |
| 179 | + * @param {Function} onSuccess 成功回调 |
| 180 | + * @param {Function} onError 失败回调 |
| 181 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/node/{id} |
| 182 | + */ |
| 183 | + nodeid(options, onSuccess, onError) { |
| 184 | + const { id } = options; |
| 185 | + let { serviceUrl } = this; |
| 186 | + let url = `${baseurl}${serviceUrl}${NodeIdPath}`; |
| 187 | + url = url.replace('{id}', id); |
| 188 | + this.get(url, onSuccess, onError); |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * @function module:CloudDisk.CalculateModelService.prototype.noderoot |
| 193 | + * @description 空间数据元数据 |
| 194 | + * @param {Function} onSuccess 成功回调 |
| 195 | + * @param {Function} onError 失败回调 |
| 196 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/node/root |
| 197 | + */ |
| 198 | + noderoot(options, onSuccess, onError) { |
| 199 | + options = {}; |
| 200 | + let { serviceUrl } = this; |
| 201 | + serviceUrl += NodeRootPath; |
| 202 | + let url = this.getFullUrl(serviceUrl, options); |
| 203 | + this.get(url, onSuccess, onError); |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * @function module:CloudDisk.CalculateModelService.prototype.nodes |
| 208 | + * @description 空间数据元数据 |
| 209 | + * @param {Function} onSuccess 成功回调 |
| 210 | + * @param {Function} onError 失败回调 |
| 211 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/nodes |
| 212 | + */ |
| 213 | + nodes(options, onSuccess, onError) { |
| 214 | + options = {}; |
| 215 | + let { serviceUrl } = this; |
| 216 | + serviceUrl += NodesPath; |
| 217 | + let url = this.getFullUrl(serviceUrl, options); |
| 218 | + this.get(url, onSuccess, onError); |
| 219 | + } |
| 220 | + |
| 221 | + /** |
| 222 | + * @function module:CloudDisk.CalculateModelService.prototype.nodesid |
| 223 | + * @description 空间数据元数据 |
| 224 | + * @param {Object} options 请求参数 |
| 225 | + * @param {String} options.nodeId 节点id |
| 226 | + * @param {Boolean} [options.subLevel = false] 是否包含子级节点 |
| 227 | + * @param {Function} onSuccess 成功回调 |
| 228 | + * @param {Function} onError 失败回调 |
| 229 | + * @example http://192.168.199.53:9011/clouddisk/rest/CalculateModel/nodes/{nodeId}?subLevel=false |
| 230 | + */ |
| 231 | + nodesid(options, onSuccess, onError) { |
| 232 | + const { nodeId } = options; |
| 233 | + let { serviceUrl } = this; |
| 234 | + let url = `${baseurl}${serviceUrl}${NodesIdPath}`; |
| 235 | + url = url.replace('{nodeId}', nodeId); |
| 236 | + delete options.nodeId; |
| 237 | + url = url + Qs.stringify(options); |
| 238 | + this.get(url, onSuccess, onError); |
| 239 | + } |
| 240 | +} |
| 241 | + |
| 242 | +export default CalculateModelService; |
| 243 | +Zondy.CloudDisk.Model.CalculateModelService = CalculateModelService; |
0 commit comments