Skip to content

Commit ea097d4

Browse files
author
杜美瑶
committed
数据发布和取消发布API --reviewed by huangqh
1 parent ac0e7c1 commit ea097d4

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

src/common/iPortal/iPortalUser.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,81 @@ export class IPortalUser extends IPortalServiceBase {
213213
}
214214
})
215215
}
216+
217+
/**
218+
* @function SuperMap.iPortalUser.prototype.publishOrUnpublish
219+
* @description 发布/取消发布。
220+
* @param {object} options - 发布/取消发布数据服务所需的参数。
221+
* @param {object} options.dataId - 数据项id。
222+
* @param {object} options.serviceType - 发布的服务类型,目前支持发布的服务类型包括:RESTDATA, RESTMAP, RESTREALSPACE, RESTSPATIALANALYST。
223+
* @param {object} [options.dataServiceId] - 发布的服务 id。
224+
* @param {boolean} forPublish - 是否取消发布。
225+
* @returns {Promise} 返回发布/取消发布数据服务的 Promise 对象。
226+
*/
227+
publishOrUnpublish(option,forPublish){
228+
if(!option.dataId || !option.serviceType) {
229+
this.getErrMsgPromise("option.dataID and option.serviceType are Required!");
230+
}
231+
var dataId = option.dataId;
232+
var dataServiceId = option.dataServiceId;
233+
var serviceType = option.serviceType;
234+
var publishUrl = this.iportalUrl + "/web/mycontent/datas/" + dataId + "/publishstatus.json?serviceType=" + serviceType;
235+
if (dataServiceId) {
236+
publishUrl += "&dataServiceId=" + dataServiceId;
237+
}
238+
return this.request("PUT",publishUrl,JSON.stringify(forPublish)).then(res=>{
239+
// 发起服务状态查询
240+
if(forPublish) {
241+
// 发布服务的结果异步处理
242+
// var publishStateUrl = this.iportalUrl + "web/mycontent/datas/" + dataId + "/publishstatus.rjson";
243+
if (!dataServiceId) { // 发布服务时会回传serviceIDs,发布服务之前serviceIDs为空
244+
dataServiceId = res.customResult;
245+
}
246+
return dataServiceId;
247+
}else {
248+
// 取消发布的结果同步处理
249+
return res;
250+
}
251+
});
252+
}
253+
254+
/**
255+
* @function SuperMap.iPortalUser.prototype.getDataPublishedStatus
256+
* @description 查询服务状态,发起服务状态查询。
257+
* @param {number} dataId - 查询服务状态的数据项id。
258+
* @param {string} dataServiceId - 发布的服务id。
259+
* @returns {Promise} 返回查询服务状态的 Promise 对象。
260+
*/
261+
getDataPublishedStatus(dataId,dataServiceId){
262+
var publishStateUrl = this.iportalUrl + "/web/mycontent/datas/" + dataId + "/publishstatus.json?dataServiceId="+dataServiceId+"&forPublish=true";
263+
return this.request("GET",publishStateUrl);
264+
}
265+
266+
/**
267+
* @function SuperMap.iPortalUser.prototype.unPublishedDataService
268+
* @description 取消发布。
269+
* @param {object} options - 取消发布服务具体参数。
270+
* @param {object} options.dataId - 数据项id。
271+
* @param {object} options.serviceType - 发布的服务类型,目前支持发布的服务类型包括:RESTDATA, RESTMAP, RESTREALSPACE, RESTSPATIALANALYST。
272+
* @param {object} [options.dataServiceId] - 发布的服务 id。
273+
* @returns {Promise} 返回取消发布数据服务的 Promise 对象。
274+
*/
275+
unPublishDataService(option){
276+
return this.publishOrUnpublish(option,false);
277+
}
278+
279+
/**
280+
* @function SuperMap.iPortalUser.prototype.publishedDataService
281+
* @description 发布数据服务。
282+
* @param {object} options - 发布数据服务具体参数。
283+
* @param {object} options.dataId - 数据项id。
284+
* @param {object} options.serviceType - 发布的服务类型,目前支持发布的服务类型包括:RESTDATA, RESTMAP, RESTREALSPACE, RESTSPATIALANALYST。
285+
* @param {object} [options.dataServiceId] - 发布的服务 id。
286+
* @returns {Promise} 返回发布数据服务的 Promise 对象。
287+
*/
288+
publishDataService(option){
289+
return this.publishOrUnpublish(option,true);
290+
}
216291
}
217292

218293
SuperMap.iPortalUser = IPortalUser;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy