33 * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44import { SuperMap } from '../SuperMap' ;
55import { IPortalServiceBase } from './iPortalServiceBase' ;
6+ import { IPortalAddResourceParam } from './iPortalAddResourceParam' ;
7+ import { IPortalRegisterServiceParam } from "./iPortalRegisterServiceParam" ;
68/**
79 * @class SuperMap.iPortalUser
810 * @classdesc iPortal 门户中用户信息的封装类。用于管理用户资源,包括可删除,添加资源。
@@ -33,6 +35,88 @@ export class IPortalUser extends IPortalServiceBase {
3335 }
3436 return this . request ( "DELETE" , deleteResourceUrl ) ;
3537 }
38+
39+ /**
40+ * @function SuperMap.iPortal.prototype.addMap
41+ * @description 添加地图。
42+ * @version 10.0.1
43+ * @param {SuperMap.iPortalAddResourceParam } addMapParams - 添加地图的参数。
44+ * @returns {Promise } 返回包含添加地图结果的 Promise 对象。
45+ */
46+ addMap ( addMapParams ) {
47+ if ( ! ( addMapParams instanceof IPortalAddResourceParam ) ) {
48+ this . getErrMsgPromise ( "addMapParams is not instanceof IPortalAddResourceParam !" ) ;
49+ }
50+ let cloneAddMapParams = {
51+ rootUrl : addMapParams . rootUrl ,
52+ tags : addMapParams . tags ,
53+ authorizeSetting : addMapParams . entities
54+ }
55+ let addMapUrl = this . iportalUrl + "/web/maps/batchaddmaps.json" ;
56+ return this . request ( "POST" , addMapUrl , JSON . stringify ( cloneAddMapParams ) ) . then ( function ( result ) {
57+ return result ;
58+ } ) ;
59+ }
60+
61+ /**
62+ * @function SuperMap.iPortal.prototype.addScene
63+ * @description 添加场景。
64+ * @version 10.0.1
65+ * @param {SuperMap.iPortalAddResourceParam } addSceneParams - 添加场景的参数。
66+ * @returns {Promise } 返回包含添加场景结果的 Promise 对象。
67+ */
68+ addScene ( addSceneParams ) {
69+ if ( ! ( addSceneParams instanceof IPortalAddResourceParam ) ) {
70+ this . getErrMsgPromise ( "addSceneParams is not instanceof IPortalAddResourceParam !" ) ;
71+ }
72+ let cloneAddSceneParams = {
73+ rootUrl : addSceneParams . rootUrl ,
74+ tags : addSceneParams . tags ,
75+ authorizeSetting : addSceneParams . entities
76+ }
77+ let addSceneUrl = this . iportalUrl + "/web/scenes/batchaddscenes.json" ;
78+ return this . request ( "POST" , addSceneUrl , JSON . stringify ( cloneAddSceneParams ) ) . then ( function ( result ) {
79+ return result ;
80+ } ) ;
81+ }
82+
83+ /**
84+ * @function SuperMap.iPortal.prototype.registerService
85+ * @description 注册服务。
86+ * @version 10.0.1
87+ * @param {SuperMap.iPortalRegisterServiceParam } registerParams - 注册服务的参数。
88+ * @returns {Promise } 返回包含注册服务结果的 Promise 对象。
89+ */
90+ registerService ( registerParams ) {
91+ if ( ! ( registerParams instanceof IPortalRegisterServiceParam ) ) {
92+ this . getErrMsgPromise ( "registerParams is not instanceof IPortalRegisterServiceParam !" ) ;
93+ }
94+ let cloneRegisterParams = {
95+ type : registerParams . type ,
96+ tags : registerParams . tags ,
97+ authorizeSetting : registerParams . entities ,
98+ metadata : registerParams . metadata ,
99+ addedMapNames : registerParams . addedMapNames ,
100+ addedSceneNames : registerParams . addedSceneNames
101+ }
102+ let registerUrl = this . iportalUrl + "/web/services.json" ;
103+ return this . request ( "POST" , registerUrl , JSON . stringify ( cloneRegisterParams ) ) . then ( result => {
104+ return result ;
105+ } ) ;
106+ }
107+
108+ /**
109+ * @function SuperMap.iPortal.prototype.getErrMsgPromise
110+ * @description 获取包含错误信息的Promise对象。
111+ * @version 10.0.1
112+ * @param {String } errMsg - 传入的错误信息。
113+ * @returns {Promise } 返回包含错误信息的 Promise 对象。
114+ */
115+ getErrMsgPromise ( errMsg ) {
116+ return new Promise ( resolve => {
117+ resolve ( errMsg ) ;
118+ } )
119+ }
36120}
37121
38122SuperMap . iPortalUser = IPortalUser ;
0 commit comments