Skip to content

Commit dc5b22b

Browse files
author
潘卓然ParnDeedlit
committed
【SDK】【服务】【新增云盘的模型服务】
1 parent 0605761 commit dc5b22b

File tree

4 files changed

+283
-33
lines changed

4 files changed

+283
-33
lines changed

src/service/clouddisk/ServiceBase.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ export class CloudDiskService extends ServiceBase {
1414
this.fixParams(options);
1515
}
1616

17+
/**
18+
*
19+
* @param {String} authorization 验证令牌
20+
*/
21+
setAuthorization(authorization) {
22+
this.options.Authorization = authorization;
23+
}
24+
1725
fixParams(option) {
1826
this.params = option;
1927
delete this.params.url;

src/service/clouddisk/file/file.js

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,40 @@ const CopyPath = 'copy';
1010
* @author 基础平台-潘卓然
1111
*/
1212
export class FileService extends CloudDiskService {
13-
constructor(options) {
14-
super(options);
13+
constructor(options) {
14+
super(options);
15+
/**
16+
* @member module:CloudDisk.FileService.prototype.serviceUrl
17+
* @description 服务地址
18+
*/
19+
this.serviceUrl = '/clouddisk/rest/file/';
20+
}
21+
1522
/**
16-
* @member module:CloudDisk.FileService.prototype.serviceUrl
17-
* @description 服务地址
23+
* @private 修正get/post需要的真正参数
1824
*/
19-
this.serviceUrl = '/clouddisk/rest/file/';
20-
}
21-
22-
/**
23-
* @private 修正get/post需要的真正参数
24-
*/
25-
fixOption(option) {
26-
this.option = {
27-
};
28-
}
29-
30-
/**
31-
* @function module:CloudDisk.FileService.prototype.schema
32-
* @description 空间数据元数据
33-
* @param {Object} options 请求参数
34-
* @param {String} options.destFileName
35-
* @param {String} options.destFolderDir
36-
* @param {String} options.isFolder
37-
* @param {String} options.srcUrl
38-
* @param {Function} onSuccess 成功回调
39-
* @param {Function} onError 失败回调
40-
* @link http://192.168.199.53:9011/giscore/dataconvert/rest/geodataset/schema?
41-
*/
42-
copy(options, onSuccess, onError) {
43-
let { serviceUrl } = this;
44-
serviceUrl += CopyPath;
45-
let url = this.getFullUrl(serviceUrl, options);
46-
this.get(url, onSuccess, onError);
47-
}
25+
fixOption(option) {
26+
this.option = {};
27+
}
4828

29+
/**
30+
* @function module:CloudDisk.FileService.prototype.schema
31+
* @description 空间数据元数据
32+
* @param {Object} options 请求参数
33+
* @param {String} options.destFileName 目地名称
34+
* @param {String} options.destFolderDir 目地目录
35+
* @param {String} options.isFolder 是否是文件夹
36+
* @param {String} options.srcUrl 原始文件或文件夹
37+
* @param {Function} onSuccess 成功回调
38+
* @param {Function} onError 失败回调
39+
* @link http://192.168.199.53:9011/clouddisk/rest/file/copy?
40+
*/
41+
copy(options, onSuccess, onError) {
42+
let { serviceUrl } = this;
43+
let baseurl = this.getBaseUrl();
44+
let url = baseurl + serviceUrl + CopyPath;
45+
this.post(url, options, onSuccess, onError);
46+
}
4947
}
5048

5149
export default FileService;
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
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;

src/service/common/Base.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Zondy.DataStore.MongoDB = Zondy.DataStore.MongoDB || {};
4949

5050
Zondy.CloudDisk = Zondy.CloudDisk || {};
5151
Zondy.CloudDisk.GisCore = Zondy.CloudDisk.GisCore || {};
52+
Zondy.CloudDisk.Model = Zondy.CloudDisk.Model || {};
5253

5354
Zondy.IGServerX = Zondy.IGServerX || {};
5455
Zondy.IGServerX.Vector = Zondy.IGServerX.Vector || {};

0 commit comments

Comments
 (0)