@ibiz-template/model-helper 0.1.9 → 0.1.10

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.
@@ -95,12 +95,14 @@ export declare class ServicePathUtil {
95
95
  * 计算递归资源路径
96
96
  *
97
97
  * @author chitanda
98
- * @date 2022-08-22 22:08:32
98
+ * @date 2023-08-23 14:08:39
99
99
  * @protected
100
+ * @param {string[]} ids
100
101
  * @param {IAppDERS[]} deRss
102
+ * @param {number} [num=0]
101
103
  * @return {*} {ServicePathDeep[]}
102
104
  */
103
- protected calcDeepPath(deRss: IAppDERS[], num?: number): ServicePathDeep[];
105
+ protected calcDeepPath(ids: string[], deRss: IAppDERS[], num?: number): ServicePathDeep[];
104
106
  /**
105
107
  * 递归填充计算所有资源路径
106
108
  *
@@ -1 +1 @@
1
- {"version":3,"file":"service-path-util.d.ts","sourceRoot":"","sources":["../../../src/utils/service-path-util/service-path-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,eAAe;IAsBxB,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE;IACnC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE;IAtBhC;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAa;IAE3D;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,CAAC,CAAa;gBAG5D,eAAe,EAAE,MAAM,EAAE,EACzB,QAAQ,EAAE,QAAQ,EAAE;IAGhC;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE;IAgB7C;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE;IAOtC;;;;;;;;OAQG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,EAAE,EAAE;IAuBpD;;;;;;;;OAQG;IACH,SAAS,CAAC,YAAY,CACpB,KAAK,EAAE,QAAQ,EAAE,EACjB,GAAG,GAAE,MAAU,GACd,eAAe,EAAE;IAapB;;;;;;;;;OASG;IACH,SAAS,CAAC,YAAY,CACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,eAAe,EAAE,GACvB,IAAI;IAmCP;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE;CAKpE"}
1
+ {"version":3,"file":"service-path-util.d.ts","sourceRoot":"","sources":["../../../src/utils/service-path-util/service-path-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,eAAe;IAsBxB,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE;IACnC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE;IAtBhC;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAa;IAE3D;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,CAAC,CAAa;gBAG5D,eAAe,EAAE,MAAM,EAAE,EACzB,QAAQ,EAAE,QAAQ,EAAE;IAGhC;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,EAAE;IAgB7C;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE;IAOtC;;;;;;;;OAQG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,EAAE,EAAE;IAyBpD;;;;;;;;;;OAUG;IACH,SAAS,CAAC,YAAY,CACpB,GAAG,EAAE,MAAM,EAAE,EACb,KAAK,EAAE,QAAQ,EAAE,EACjB,GAAG,GAAE,MAAU,GACd,eAAe,EAAE;IAuBpB;;;;;;;;;OASG;IACH,SAAS,CAAC,YAAY,CACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EAAE,EACnB,KAAK,EAAE,eAAe,EAAE,GACvB,IAAI;IAmCP;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,GAAG,eAAe,EAAE,EAAE;CAKpE"}
@@ -88,7 +88,9 @@ export class ServicePathUtil {
88
88
  }
89
89
  const deRss = this.filterDERSs(id);
90
90
  if (deRss) {
91
- const arr = this.calcDeepPath(deRss);
91
+ // 已经计算过的应用实体标识
92
+ const ids = [id];
93
+ const arr = this.calcDeepPath(ids, deRss);
92
94
  this.deepFillPath(codeName, [codeName], arr);
93
95
  let paths = this.entityRsPathMap.get(codeName);
94
96
  if (paths) {
@@ -103,20 +105,27 @@ export class ServicePathUtil {
103
105
  * 计算递归资源路径
104
106
  *
105
107
  * @author chitanda
106
- * @date 2022-08-22 22:08:32
108
+ * @date 2023-08-23 14:08:39
107
109
  * @protected
110
+ * @param {string[]} ids
108
111
  * @param {IAppDERS[]} deRss
112
+ * @param {number} [num=0]
109
113
  * @return {*} {ServicePathDeep[]}
110
114
  */
111
- calcDeepPath(deRss, num = 0) {
115
+ calcDeepPath(ids, deRss, num = 0) {
112
116
  if (num > 10) {
113
117
  throw new Error('服务路径计算超过最大层级 10');
114
118
  }
115
119
  num += 1;
116
120
  const arr = [];
117
121
  deRss.forEach(rs => {
122
+ if (ids.includes(rs.majorAppDataEntityId)) {
123
+ ibiz.log.warn('计算资源关系路径出现循环递归引用,触发实体:', rs.majorAppDataEntityId, '当前已计算过实体清单: ', ids);
124
+ return;
125
+ }
126
+ ids.push(rs.majorAppDataEntityId);
118
127
  const items = this.filterDERSs(rs.majorAppDataEntityId);
119
- arr.push([rs, this.calcDeepPath(items, num)]);
128
+ arr.push([rs, this.calcDeepPath(ids, items, num)]);
120
129
  });
121
130
  return arr;
122
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/model-helper",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "控制器包",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -29,16 +29,16 @@
29
29
  "author": "chitanda",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@ibiz/model-core": "^0.0.14",
33
- "@ibiz/rt-model-api": "^0.1.9",
32
+ "@ibiz/model-core": "^0.0.15",
33
+ "@ibiz/rt-model-api": "^0.1.10",
34
34
  "pluralize": "^8.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@ibiz-template/runtime": "^0.1.9",
37
+ "@ibiz-template/runtime": "^0.1.10",
38
38
  "@types/pluralize": "^0.0.30"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@ibiz-template/runtime": "^0.1.0"
42
42
  },
43
- "gitHead": "996ad2a8bc9cd856f5a672ebdc97748124c07da1"
43
+ "gitHead": "24e2a2f4b050fbb3a3b9f5deeee97f98985913e4"
44
44
  }
@@ -130,7 +130,9 @@ export class ServicePathUtil {
130
130
  }
131
131
  const deRss = this.filterDERSs(id);
132
132
  if (deRss) {
133
- const arr = this.calcDeepPath(deRss);
133
+ // 已经计算过的应用实体标识
134
+ const ids: string[] = [id];
135
+ const arr = this.calcDeepPath(ids, deRss);
134
136
  this.deepFillPath(codeName, [codeName], arr);
135
137
  let paths = this.entityRsPathMap.get(codeName);
136
138
  if (paths) {
@@ -146,12 +148,15 @@ export class ServicePathUtil {
146
148
  * 计算递归资源路径
147
149
  *
148
150
  * @author chitanda
149
- * @date 2022-08-22 22:08:32
151
+ * @date 2023-08-23 14:08:39
150
152
  * @protected
153
+ * @param {string[]} ids
151
154
  * @param {IAppDERS[]} deRss
155
+ * @param {number} [num=0]
152
156
  * @return {*} {ServicePathDeep[]}
153
157
  */
154
158
  protected calcDeepPath(
159
+ ids: string[],
155
160
  deRss: IAppDERS[],
156
161
  num: number = 0,
157
162
  ): ServicePathDeep[] {
@@ -161,8 +166,18 @@ export class ServicePathUtil {
161
166
  num += 1;
162
167
  const arr: ServicePathDeep[] = [];
163
168
  deRss.forEach(rs => {
169
+ if (ids.includes(rs.majorAppDataEntityId!)) {
170
+ ibiz.log.warn(
171
+ '计算资源关系路径出现循环递归引用,触发实体:',
172
+ rs.majorAppDataEntityId,
173
+ '当前已计算过实体清单: ',
174
+ ids,
175
+ );
176
+ return;
177
+ }
178
+ ids.push(rs.majorAppDataEntityId!);
164
179
  const items = this.filterDERSs(rs.majorAppDataEntityId!);
165
- arr.push([rs, this.calcDeepPath(items, num)]);
180
+ arr.push([rs, this.calcDeepPath(ids, items, num)]);
166
181
  });
167
182
  return arr;
168
183
  }