@ibiz-template/model-helper 0.7.41-alpha.13 → 0.7.41-alpha.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/index.esm.js +9770 -3196
  2. package/dist/index.system.min.js +1 -1
  3. package/out/index.d.ts +2 -1
  4. package/out/index.d.ts.map +1 -1
  5. package/out/index.js +1 -1
  6. package/out/interface/i-model-handler.d.ts +20 -0
  7. package/out/interface/i-model-handler.d.ts.map +1 -0
  8. package/out/interface/i-model-handler.js +1 -0
  9. package/out/interface/index.d.ts +2 -0
  10. package/out/interface/index.d.ts.map +1 -0
  11. package/out/interface/index.js +1 -0
  12. package/out/locale/en/index.d.ts +4 -0
  13. package/out/locale/en/index.d.ts.map +1 -1
  14. package/out/locale/en/index.js +4 -0
  15. package/out/locale/zh-CN/index.d.ts +4 -0
  16. package/out/locale/zh-CN/index.d.ts.map +1 -1
  17. package/out/locale/zh-CN/index.js +4 -0
  18. package/out/model-helper.d.ts +13 -1
  19. package/out/model-helper.d.ts.map +1 -1
  20. package/out/model-helper.js +47 -4
  21. package/out/model-loader.d.ts +3 -1
  22. package/out/model-loader.d.ts.map +1 -1
  23. package/out/model-loader.js +6 -0
  24. package/out/model-util.d.ts +3 -2
  25. package/out/model-util.d.ts.map +1 -1
  26. package/out/model-util.js +28 -20
  27. package/out/utils/index.d.ts +3 -0
  28. package/out/utils/index.d.ts.map +1 -1
  29. package/out/utils/index.js +3 -0
  30. package/out/utils/merge-model/merge-app-codelist.d.ts +8 -0
  31. package/out/utils/merge-model/merge-app-codelist.d.ts.map +1 -0
  32. package/out/utils/merge-model/merge-app-codelist.js +35 -0
  33. package/out/utils/merge-model/merge-app-menu.d.ts.map +1 -1
  34. package/out/utils/merge-model/merge-app-menu.js +8 -3
  35. package/out/utils/merge-model/merge-app-uiaction-group.d.ts +7 -0
  36. package/out/utils/merge-model/merge-app-uiaction-group.d.ts.map +1 -1
  37. package/out/utils/merge-model/merge-app-uiaction-group.js +54 -2
  38. package/out/utils/merge-model/merge-de-drcontrol.d.ts +8 -0
  39. package/out/utils/merge-model/merge-de-drcontrol.d.ts.map +1 -1
  40. package/out/utils/merge-model/merge-de-drcontrol.js +87 -4
  41. package/out/utils/merge-model/merge-de-form.d.ts +15 -0
  42. package/out/utils/merge-model/merge-de-form.d.ts.map +1 -1
  43. package/out/utils/merge-model/merge-de-form.js +56 -0
  44. package/out/utils/merge-model/merge-model-helper.d.ts +15 -1
  45. package/out/utils/merge-model/merge-model-helper.d.ts.map +1 -1
  46. package/out/utils/merge-model/merge-model-helper.js +101 -9
  47. package/out/utils/merge-model/merge-treeview.d.ts.map +1 -1
  48. package/out/utils/merge-model/merge-treeview.js +142 -6
  49. package/out/utils/model-transformer/model-handler.d.ts +32 -0
  50. package/out/utils/model-transformer/model-handler.d.ts.map +1 -0
  51. package/out/utils/model-transformer/model-handler.js +24 -0
  52. package/out/utils/model-transformer/model-register.d.ts +9 -0
  53. package/out/utils/model-transformer/model-register.d.ts.map +1 -0
  54. package/out/utils/model-transformer/model-register.js +10 -0
  55. package/out/utils/model-transformer/model-transformer.d.ts +63 -0
  56. package/out/utils/model-transformer/model-transformer.d.ts.map +1 -0
  57. package/out/utils/model-transformer/model-transformer.js +125 -0
  58. package/package.json +8 -6
  59. package/src/index.ts +12 -0
  60. package/src/interface/i-model-handler.ts +19 -0
  61. package/src/interface/index.ts +1 -0
  62. package/src/locale/en/index.ts +24 -0
  63. package/src/locale/index.ts +2 -0
  64. package/src/locale/zh-CN/index.ts +20 -0
  65. package/src/model/PSSYSAPP.ts +12 -0
  66. package/src/model-helper.ts +804 -0
  67. package/src/model-loader.ts +95 -0
  68. package/src/model-util.ts +483 -0
  69. package/src/utils/format-path/format-path.ts +9 -0
  70. package/src/utils/index.ts +12 -0
  71. package/src/utils/merge-model/merge-app-codelist.ts +42 -0
  72. package/src/utils/merge-model/merge-app-menu.ts +136 -0
  73. package/src/utils/merge-model/merge-app-uiaction-group.ts +85 -0
  74. package/src/utils/merge-model/merge-de-drcontrol.ts +175 -0
  75. package/src/utils/merge-model/merge-de-form.ts +326 -0
  76. package/src/utils/merge-model/merge-model-helper.ts +602 -0
  77. package/src/utils/merge-model/merge-model.ts +20 -0
  78. package/src/utils/merge-model/merge-treeview.ts +197 -0
  79. package/src/utils/model-transformer/model-handler.ts +36 -0
  80. package/src/utils/model-transformer/model-register.ts +15 -0
  81. package/src/utils/model-transformer/model-transformer.ts +147 -0
  82. package/src/utils/plural/plural.ts +30 -0
  83. package/src/utils/service-path-util/service-path-util.ts +361 -0
@@ -0,0 +1,95 @@
1
+ import { ModelLoaderProvider } from '@ibiz-template/runtime';
2
+ import {
3
+ IApplication,
4
+ IAppView,
5
+ IAppDataEntity,
6
+ IAppBIScheme,
7
+ IAppBICube,
8
+ IAppBIReport,
9
+ ISubAppRef,
10
+ IAppCodeList,
11
+ IAppLan,
12
+ } from '@ibiz/model-core';
13
+ import { ModelHelper } from './model-helper';
14
+
15
+ /**
16
+ * 模型加载适配器
17
+ *
18
+ * @author chitanda
19
+ * @date 2023-04-17 23:04:44
20
+ * @export
21
+ * @class ModelLoader
22
+ * @implements {ModelLoaderProvider}
23
+ */
24
+ export class ModelLoader implements ModelLoaderProvider {
25
+ constructor(protected helper: ModelHelper) {}
26
+
27
+ initApp(id?: string): Promise<boolean> {
28
+ return this.helper.initApp(id);
29
+ }
30
+
31
+ getApp(id?: string): Promise<IApplication> {
32
+ return this.helper.getAppModel(id);
33
+ }
34
+
35
+ getSubAppRef(appId: string): Promise<ISubAppRef | undefined> {
36
+ return this.helper.getSubAppRef(appId);
37
+ }
38
+
39
+ getAppView(appId: string, codeName: string): Promise<IAppView> {
40
+ return this.helper.getAppViewModel(codeName, appId);
41
+ }
42
+
43
+ getAppDataEntity(appId: string, id: string): Promise<IAppDataEntity> {
44
+ return this.helper.getAppDataEntityModel(id, appId);
45
+ }
46
+
47
+ getAppDataEntityByCodeName(
48
+ appId: string,
49
+ codeName: string,
50
+ ): Promise<IAppDataEntity> {
51
+ return this.helper.getAppDataEntityModel(codeName, appId, false);
52
+ }
53
+
54
+ async getPSAppLang(
55
+ language: string,
56
+ appId?: string | IObject,
57
+ ): Promise<IAppLan | null> {
58
+ return this.helper.getPSAppLang(language, appId);
59
+ }
60
+
61
+ getAppStyle(appId: string): Promise<string | null> {
62
+ return this.helper.getAppStyle(appId);
63
+ }
64
+
65
+ loadAppView(
66
+ appId: string,
67
+ viewId: string,
68
+ params: IParams,
69
+ ): Promise<IAppView> {
70
+ return this.helper.loadAppViewModel(viewId, params, appId);
71
+ }
72
+
73
+ getAppBISchemes(appId: string, ids: string[]): Promise<IAppBIScheme[]> {
74
+ return this.helper.getAppBISchemes(appId, ids);
75
+ }
76
+
77
+ getAppAppBICubes(appId: string, ids: string[]): Promise<IAppBICube[]> {
78
+ return this.helper.getAppAppBICubes(appId, ids);
79
+ }
80
+
81
+ getAppBIReports(appId: string, ids: string[]): Promise<IAppBIReport[]> {
82
+ return this.helper.getAppBIReports(appId, ids);
83
+ }
84
+
85
+ translationModelToDsl(
86
+ data: IData,
87
+ type: 'APP' | 'VIEW' | 'CTRL' | 'APPENTITY' | 'APPBIREPORT',
88
+ ): Promise<IModel | undefined> {
89
+ return this.helper.translationModelToDsl(data, type);
90
+ }
91
+
92
+ mergeSubAppCodeList(codeList: IAppCodeList): void {
93
+ this.helper.mergeSubAppCodeList(codeList);
94
+ }
95
+ }
@@ -0,0 +1,483 @@
1
+ import { calcUniqueTag } from '@ibiz/rt-model-api';
2
+ import { IAppDERS } from '@ibiz/model-core';
3
+ import { isEmpty } from 'ramda';
4
+ import {
5
+ formatPath,
6
+ mergeModel,
7
+ ModelTransformer,
8
+ ServicePathUtil,
9
+ } from './utils';
10
+ import { PSSysApp } from './model/PSSYSAPP';
11
+
12
+ /**
13
+ * 全动模型处理工具类,每个App一个实例
14
+ *
15
+ * @author chitanda
16
+ * @date 2023-04-16 17:04:06
17
+ * @export
18
+ * @class ModelUtil
19
+ */
20
+ export class ModelUtil {
21
+ /**
22
+ * 模型缓存
23
+ *
24
+ * @author chitanda
25
+ * @date 2023-04-16 17:04:40
26
+ * @protected
27
+ * @type {Map<string, IModel>}
28
+ */
29
+ protected modelCache: Map<string, IModel> = new Map();
30
+
31
+ /**
32
+ * 应用模型
33
+ *
34
+ * @author chitanda
35
+ * @date 2023-04-16 17:04:17
36
+ * @protected
37
+ * @type {IModel}
38
+ */
39
+ protected appModel!: IModel;
40
+
41
+ /**
42
+ * 服务路径计算工具类
43
+ *
44
+ * @author chitanda
45
+ * @date 2023-04-22 12:04:15
46
+ * @type {ServicePathUtil}
47
+ */
48
+ servicePathUtil!: ServicePathUtil;
49
+
50
+ /**
51
+ * Creates an instance of GlobalModel.
52
+ *
53
+ * @author chitanda
54
+ * @date 2023-04-13 21:04:21
55
+ * @param {string}appId 应用标识
56
+ * @param {string} modelTag
57
+ * @param {(url: string, params?: IParams) => Promise<IModel>} get 模型加载方法
58
+ * @param {boolean} hub 是否为 hub 应用基座
59
+ * @param {IParams} appContext 应用级上下文参数
60
+ */
61
+ constructor(
62
+ protected appId: string,
63
+ protected modelTag: string,
64
+ protected get: (url: string, params?: IParams) => Promise<IModel>,
65
+ protected hub: boolean,
66
+ protected appContext: IParams,
67
+ protected permission: boolean = true,
68
+ ) {}
69
+
70
+ /**
71
+ * 在使用前需要初始化,来进行异步加载
72
+ *
73
+ * @author chitanda
74
+ * @date 2023-04-16 17:04:35
75
+ * @return {*} {Promise<void>}
76
+ */
77
+ async init(): Promise<void> {
78
+ await this.getAppModel();
79
+ await this.specialHandling();
80
+ // 填充缓存模型
81
+ {
82
+ const { cache } = this.appModel;
83
+ if (cache) {
84
+ const views = cache.getPSAppViews;
85
+ if (views) {
86
+ views.forEach((item: IModel) => {
87
+ item.path = item.dynaModelFilePath;
88
+ const appPath = this.calcAppPath(item.path);
89
+ this.modelCache.set(appPath, item);
90
+ });
91
+ if (this.appModel.getAllPSAppViews == null) {
92
+ this.appModel.getAllPSAppViews = views;
93
+ } else {
94
+ this.appModel.getAllPSAppViews.push(...views);
95
+ }
96
+ }
97
+ }
98
+ }
99
+ const allDataEntities = (this.appModel.getAllPSAppDataEntities ||
100
+ []) as IModel[];
101
+ allDataEntities.forEach(item => {
102
+ item.id = calcUniqueTag(item, false);
103
+ });
104
+ const allViews = (this.appModel.getAllPSAppViews || []) as IModel[];
105
+ allViews.forEach(item => {
106
+ item.id = calcUniqueTag(item, false);
107
+ });
108
+ const allAppDERSs = (this.appModel.getAllPSAppDERSs || []) as IModel[];
109
+ allAppDERSs.forEach(item => {
110
+ const major = item.getMajorPSAppDataEntity;
111
+ const minor = item.getMinorPSAppDataEntity;
112
+ item.majorAppDataEntityId = calcUniqueTag(major, false);
113
+ item.minorAppDataEntityId = calcUniqueTag(minor, false);
114
+ });
115
+ this.servicePathUtil = new ServicePathUtil(
116
+ allDataEntities,
117
+ allAppDERSs as IAppDERS[],
118
+ this,
119
+ );
120
+ }
121
+
122
+ /**
123
+ * 特殊处理应用模型
124
+ *
125
+ * @author chitanda
126
+ * @date 2023-09-21 15:09:07
127
+ * @protected
128
+ * @return {*} {Promise<void>}
129
+ */
130
+ protected async specialHandling(): Promise<void> {
131
+ // 特殊处理预置全局界面行为,附加一些特殊的模板预置模型
132
+ if (this.appModel.getAllPSAppDEUIActions) {
133
+ mergeModel(
134
+ this.appModel.getAllPSAppDEUIActions,
135
+ PSSysApp.getAllPSAppDEUIActions,
136
+ 'codeName',
137
+ );
138
+ }
139
+ }
140
+
141
+ /**
142
+ * 获取应用模型
143
+ *
144
+ * @author chitanda
145
+ * @date 2023-04-16 17:04:21
146
+ * @return {*} {Promise<IModel>}
147
+ */
148
+ async getAppModel(): Promise<IModel> {
149
+ if (!this.appModel) {
150
+ let appPath: string = '/PSSYSAPP.json';
151
+ if (this.hub && ibiz.env.hub) {
152
+ appPath = `/PSSYSAPP.hub.json`;
153
+ }
154
+ if (this.permission === false) {
155
+ appPath = `/simple/PSSYSAPP.simple.json`;
156
+ }
157
+ this.appModel = await this.getModel(appPath);
158
+ this.appModel.id = this.appId;
159
+ }
160
+ return this.appModel;
161
+ }
162
+
163
+ /**
164
+ * 加载应用模型全局样式
165
+ *
166
+ * @author chitanda
167
+ * @date 2023-09-06 10:09:11
168
+ * @return {*} {(Promise<string | null>)}
169
+ */
170
+ async getAppStyle(): Promise<string | null> {
171
+ let style: string = '';
172
+ try {
173
+ let stylePath: string = '/PSSYSAPP.json.css';
174
+ if (this.hub && ibiz.env.hub) {
175
+ stylePath = `/PSSYSAPP.hubsubapp.json.css`;
176
+ }
177
+ if (this.permission === false) {
178
+ stylePath = `/simple/PSSYSAPP.simple.json.css`;
179
+ }
180
+ style = await this.getStyleModel(stylePath);
181
+ if (style) {
182
+ return style;
183
+ }
184
+ } catch (error) {
185
+ // 忽略样式加载异常
186
+ ibiz.log.error(error);
187
+ }
188
+ return null;
189
+ }
190
+
191
+ /**
192
+ * 根据应用实体 codeName 或者 id 获取应用实体模型
193
+ *
194
+ * @author chitanda
195
+ * @date 2023-04-16 18:04:45
196
+ * @param {string} tag
197
+ * @param {boolean} [isId=true]
198
+ * @param {boolean} [ignoreCase=false]
199
+ * @return {*} {Promise<IModel>}
200
+ */
201
+ async getAppDataEntityModel(
202
+ tag: string,
203
+ isId: boolean = true,
204
+ ignoreCase: boolean = false,
205
+ ): Promise<IModel> {
206
+ const allDataEntities = this.appModel.getAllPSAppDataEntities as IModel[];
207
+ if (allDataEntities && allDataEntities.length > 0) {
208
+ const lowerTag = tag.toLowerCase();
209
+ let dataEntity: IModel | undefined;
210
+ if (isId) {
211
+ dataEntity = allDataEntities.find(v => {
212
+ if (ignoreCase) {
213
+ return v.id.toLowerCase() === lowerTag;
214
+ }
215
+ return v.id === tag;
216
+ });
217
+ } else {
218
+ dataEntity = allDataEntities.find(v => {
219
+ if (ignoreCase) {
220
+ return v.codeName.toLowerCase() === lowerTag;
221
+ }
222
+ return v.codeName === tag;
223
+ });
224
+ }
225
+ if (dataEntity) {
226
+ return this.getModel(dataEntity.path);
227
+ }
228
+ }
229
+
230
+ throw new Error(
231
+ ibiz.i18n.t('modelHelper.noFoundEntity', { appId: this.appId, tag }),
232
+ );
233
+ }
234
+
235
+ /**
236
+ * 根据应用视图 id 获取应用视图模型,如果给了 params 则每次都会重新加载模型
237
+ *
238
+ * @author chitanda
239
+ * @date 2024-01-15 12:01:36
240
+ * @param {string} tag
241
+ * @param {IParams} [params]
242
+ * @param {boolean} [isDynamic]
243
+ * @return {*} {Promise<IModel>}
244
+ */
245
+ async getAppViewModel(
246
+ tag: string,
247
+ params?: IParams,
248
+ isDynamic?: boolean,
249
+ ): Promise<IModel> {
250
+ const allViews = this.appModel.getAllPSAppViews as IModel[];
251
+ if (allViews && allViews.length > 0) {
252
+ const lowerTag = tag.toLowerCase();
253
+ const exTag = `.${lowerTag}`;
254
+ const view = allViews.find(
255
+ v => v.id.endsWith(exTag) || v.id === lowerTag,
256
+ );
257
+ if (view) {
258
+ return this.getModel(view.path, params, isDynamic);
259
+ }
260
+ }
261
+ throw new Error(
262
+ ibiz.i18n.t('modelHelper.noFoundView', { appId: this.appId, tag }),
263
+ );
264
+ }
265
+
266
+ /**
267
+ * 加载应用多语言模型
268
+ *
269
+ * @author chitanda
270
+ * @date 2023-08-24 22:08:23
271
+ * @param {string} language
272
+ * @return {*} {Promise<IModel>}
273
+ */
274
+ async getPSAppLang(language: string): Promise<IModel> {
275
+ const app = await this.getAppModel();
276
+ if (app.getAllPSAppLans) {
277
+ const langs = app.getAllPSAppLans as IModel[];
278
+ const lang = langs.find(item => item.language === language);
279
+ if (lang) {
280
+ try {
281
+ const result = await this.getModel(
282
+ lang.path || lang.dynaModelFilePath,
283
+ );
284
+ return result;
285
+ } catch (error) {
286
+ ibiz.log.error(error);
287
+ return {};
288
+ }
289
+ }
290
+ ibiz.log.error(ibiz.i18n.t('modelHelper.noSupported', { language }));
291
+ }
292
+ return {};
293
+ }
294
+
295
+ /**
296
+ * 加载应用样式字符串
297
+ *
298
+ * @author chitanda
299
+ * @date 2023-09-07 11:09:11
300
+ * @param {string} modelPath
301
+ * @return {*} {Promise<string>}
302
+ */
303
+ getStyleModel(modelPath: string): Promise<string> {
304
+ let url: string;
305
+ if (this.hub) {
306
+ url = this.calcAppPath(modelPath);
307
+ } else {
308
+ url = this.calcSubAppPath(modelPath);
309
+ }
310
+ return this.get(url) as unknown as Promise<string>;
311
+ }
312
+
313
+ /**
314
+ * 获取应用智能报表体系集合
315
+ *
316
+ * @author tony001
317
+ * @date 2024-06-04 16:06:19
318
+ * @param {IModel[]} model
319
+ * @return {*} {Promise<IModel[]>}
320
+ */
321
+ async getAppBISchemeModel(model: IModel[] = []): Promise<IModel[]> {
322
+ const appBISchemeModel: IModel[] = [];
323
+ if (model.length > 0) {
324
+ for (let i = 0; i < model.length; i++) {
325
+ const appBISchemeItem = await this.getModel(model[i].path);
326
+ appBISchemeModel.push(appBISchemeItem);
327
+ }
328
+ }
329
+ return appBISchemeModel;
330
+ }
331
+
332
+ /**
333
+ * 获取应用智能报表立方体数据集合
334
+ *
335
+ * @author tony001
336
+ * @date 2024-06-04 16:06:19
337
+ * @param {IModel[]} [model=[]]
338
+ * @return {*} {Promise<IModel[]>}
339
+ */
340
+ async getAppAppBICubes(model: IModel[] = []): Promise<IModel[]> {
341
+ const appBICubeModel: IModel[] = [];
342
+ if (model.length > 0) {
343
+ for (let i = 0; i < model.length; i++) {
344
+ const appBICubeItem = await this.getModel(model[i].path);
345
+ appBICubeModel.push(appBICubeItem);
346
+ }
347
+ }
348
+ return appBICubeModel;
349
+ }
350
+
351
+ /**
352
+ * 获取应用智能报表数据集合
353
+ *
354
+ * @author tony001
355
+ * @date 2024-06-04 16:06:29
356
+ * @param {IModel[]} [model=[]]
357
+ * @return {*} {Promise<IModel[]>}
358
+ */
359
+ async getAppBIReports(model: IModel[] = []): Promise<IModel[]> {
360
+ const appBIReportModel: IModel[] = [];
361
+ if (model.length > 0) {
362
+ for (let i = 0; i < model.length; i++) {
363
+ const appBIReportItem = await this.getModel(model[i].path);
364
+ appBIReportModel.push(appBIReportItem);
365
+ }
366
+ }
367
+ return appBIReportModel;
368
+ }
369
+
370
+ /**
371
+ * 加载模型,如果给了 params 则不会缓存模型
372
+ *
373
+ * @author chitanda
374
+ * @date 2024-01-15 12:01:57
375
+ * @param {string} modelPath
376
+ * @param {IParams} [params]
377
+ * @param {boolean} [isDynamic]
378
+ * @return {*} {Promise<IModel>}
379
+ */
380
+ async getModel(
381
+ modelPath: string,
382
+ params?: IParams,
383
+ isDynamic?: boolean,
384
+ ): Promise<IModel> {
385
+ let url: string;
386
+ if (this.hub) {
387
+ url = this.calcAppPath(modelPath, isDynamic);
388
+ } else {
389
+ url = this.calcSubAppPath(modelPath, isDynamic);
390
+ }
391
+ const isParams = params && !isEmpty(params);
392
+ if (this.modelCache.has(url) && !isParams) {
393
+ return this.modelCache.get(url)!;
394
+ }
395
+ const model = await this.get(url, params);
396
+ const filledModel = this.deepFillModel(model);
397
+ if (!isParams) {
398
+ this.modelCache.set(url, filledModel);
399
+ }
400
+ return filledModel;
401
+ }
402
+
403
+ /**
404
+ * 递归填充模型,包括填充模型appId、变换模型
405
+ *
406
+ * @author chitanda
407
+ * @date 2023-08-21 10:08:41
408
+ * @protected
409
+ * @param {IModel} model
410
+ * @return {*} {IModel} 返回处理后的模型,若处理器返回新对象则替换原引用
411
+ */
412
+ protected deepFillModel(model: IModel): IModel {
413
+ // 变换模型
414
+ let result = model;
415
+ if (model.dynaModelFilePath) {
416
+ result = ModelTransformer.getInstance().transform(
417
+ model.dynaModelFilePath,
418
+ model,
419
+ );
420
+ }
421
+ // 填充模型appId
422
+ result.appId = this.appId;
423
+ const keys = Object.keys(result);
424
+ keys.forEach(key => {
425
+ const value = result[key];
426
+ if (value && typeof value === 'object') {
427
+ if (Array.isArray(value)) {
428
+ value.forEach((item, index) => {
429
+ if (item && typeof item === 'object') {
430
+ value[index] = this.deepFillModel(item);
431
+ }
432
+ });
433
+ } else {
434
+ result[key] = this.deepFillModel(value);
435
+ }
436
+ }
437
+ });
438
+ return result;
439
+ }
440
+
441
+ /**
442
+ * 计算应用模型请求路径
443
+ *
444
+ * @author chitanda
445
+ * @date 2024-01-15 12:01:45
446
+ * @protected
447
+ * @param {string} modelPath
448
+ * @param {boolean} [isDynamic=false]
449
+ * @return {*} {string}
450
+ */
451
+ protected calcAppPath(modelPath: string, isDynamic: boolean = false): string {
452
+ if (isDynamic) {
453
+ return formatPath(modelPath);
454
+ }
455
+ return `${formatPath(modelPath)}${
456
+ this.modelTag
457
+ ? `?dynamodeltag=${this.modelTag}${this.appContext && this.appContext.srfembsubapp ? `&srfembsubapp=${this.appContext.srfembsubapp}` : ''}`
458
+ : ''
459
+ }`;
460
+ }
461
+
462
+ /**
463
+ * 计算子应用模型请求路径
464
+ *
465
+ * @author chitanda
466
+ * @date 2024-01-15 12:01:39
467
+ * @protected
468
+ * @param {string} modelPath
469
+ * @param {boolean} [isDynamic=false]
470
+ * @return {*} {string}
471
+ */
472
+ protected calcSubAppPath(
473
+ modelPath: string,
474
+ isDynamic: boolean = false,
475
+ ): string {
476
+ if (isDynamic) {
477
+ return `/subapps/${this.appId}${formatPath(modelPath)}`;
478
+ }
479
+ return `/subapps/${this.appId}${formatPath(modelPath)}?dynamodeltag=${
480
+ this.modelTag
481
+ }`;
482
+ }
483
+ }
@@ -0,0 +1,9 @@
1
+ export function formatPath(path: string): string {
2
+ // 合成路径,需要判断模型路径是否从 PSSYSAPPS 开始
3
+ if (path?.indexOf('PSSYSAPPS/') === 0) {
4
+ // 合成路径
5
+ const pos = path.indexOf('/');
6
+ return path.substring(path.indexOf('/', pos + 1));
7
+ }
8
+ return path;
9
+ }
@@ -0,0 +1,12 @@
1
+ export { formatPath } from './format-path/format-path';
2
+ export { mergeModel } from './merge-model/merge-model';
3
+ export { plural, pluralLower } from './plural/plural';
4
+ export {
5
+ ServicePathDeep,
6
+ ServicePathItem,
7
+ ServicePathUtil,
8
+ } from './service-path-util/service-path-util';
9
+ export { MergeSubModelHelper } from './merge-model/merge-model-helper';
10
+ export { ModelHandler } from './model-transformer/model-handler';
11
+ export { ModelTransformer } from './model-transformer/model-transformer';
12
+ export { registerModelHandler } from './model-transformer/model-register';
@@ -0,0 +1,42 @@
1
+ import { IAppCodeList } from '@ibiz/model-core';
2
+
3
+ /**
4
+ * 合并应用代码表,子应用代码表需开启支持动态模式和配置用户标记,合并规则:dynamic_overlay:replace|merge,replace表示子应用代码表完全覆盖主应用代码表,merge表示子应用代码表项合并到主应用代码表项中(前提条件:主应用代码表和子应用代码表均是静态代码表),其他情况不做处理
5
+ * @param mainCodeList - 主应用代码表
6
+ * @param subCodeList - 子应用代码表
7
+ */
8
+ export function mergeAppCodeList(
9
+ mainCodeList: IAppCodeList,
10
+ subCodeList: IAppCodeList,
11
+ ): void {
12
+ const { userTag } = subCodeList as IModel;
13
+ if (!userTag) return;
14
+ const [mergeTag, mergeWay] = userTag.split(':');
15
+ if (
16
+ !mergeTag ||
17
+ !mergeWay ||
18
+ mergeTag !== 'dynamic_overlay' ||
19
+ (mergeWay !== 'replace' && mergeWay !== 'merge')
20
+ )
21
+ return;
22
+ switch (mergeWay) {
23
+ case 'replace':
24
+ mainCodeList = subCodeList;
25
+ break;
26
+ case 'merge':
27
+ if (
28
+ mainCodeList.codeListType === 'STATIC' &&
29
+ subCodeList.codeListType === 'STATIC'
30
+ ) {
31
+ if (!mainCodeList.codeItems) mainCodeList.codeItems = [];
32
+ if (subCodeList.codeItems && subCodeList.codeItems.length > 0) {
33
+ subCodeList.codeItems.forEach(codeItem => {
34
+ mainCodeList.codeItems!.push(codeItem);
35
+ });
36
+ }
37
+ }
38
+ break;
39
+ default:
40
+ break;
41
+ }
42
+ }