rez_core 3.1.181 → 3.1.183
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.
- package/dist/module/filter/service/filter.service.js +16 -4
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +3 -1
- package/dist/module/mapper/service/field-mapper.service.js +27 -17
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/meta/controller/entity.public.controller.d.ts +12 -0
- package/dist/module/meta/controller/entity.public.controller.js +75 -0
- package/dist/module/meta/controller/entity.public.controller.js.map +1 -0
- package/dist/module/meta/entity.module.js +4 -2
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/workflow/service/stage-group.service.d.ts +3 -1
- package/dist/module/workflow/service/stage-group.service.js +23 -6
- package/dist/module/workflow/service/stage-group.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/filter/service/filter.service.ts +108 -81
- package/src/module/mapper/service/field-mapper.service.ts +25 -3
- package/src/module/meta/controller/entity.public.controller.ts +75 -0
- package/src/module/meta/entity.module.ts +4 -2
- package/src/module/workflow/service/stage-group.service.ts +37 -7
package/package.json
CHANGED
|
@@ -84,15 +84,17 @@ export class FilterService {
|
|
|
84
84
|
attributeFilter = [],
|
|
85
85
|
loggedInUser,
|
|
86
86
|
} = dto;
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
|
|
89
88
|
// 🔹 Step 1: Collect all filters (from body + savedFilter)
|
|
90
|
-
const savedFilters = await this.getSavedFilters(
|
|
91
|
-
|
|
92
|
-
(f) => f.filter_value !== '',
|
|
89
|
+
const savedFilters = await this.getSavedFilters(
|
|
90
|
+
savedFilterCode ?? undefined,
|
|
93
91
|
);
|
|
92
|
+
const allFilters = [
|
|
93
|
+
...quickFilter,
|
|
94
|
+
...attributeFilter,
|
|
95
|
+
...savedFilters,
|
|
96
|
+
].filter((f) => f.filter_value !== '');
|
|
94
97
|
|
|
95
|
-
|
|
96
98
|
// 🔹 Step 2: Group filters by filter_entity_type
|
|
97
99
|
const grouped = allFilters.reduce(
|
|
98
100
|
(acc, f) => {
|
|
@@ -102,16 +104,16 @@ export class FilterService {
|
|
|
102
104
|
},
|
|
103
105
|
{} as Record<string, any[]>,
|
|
104
106
|
);
|
|
105
|
-
|
|
107
|
+
|
|
106
108
|
console.log('🟠 [FilterService] Grouped filters by entity type:', grouped);
|
|
107
|
-
|
|
109
|
+
|
|
108
110
|
// 🔹 Step 3: Handle sub-entities first
|
|
109
111
|
let intersectionIds: number[] | null = null;
|
|
110
112
|
for (const [subEntityType, filters] of Object.entries(grouped)) {
|
|
111
113
|
if (subEntityType === entity_type) continue; // skip main entity for now
|
|
112
|
-
|
|
114
|
+
|
|
113
115
|
let { queryParams, tabs, ...newDto } = dto;
|
|
114
|
-
|
|
116
|
+
|
|
115
117
|
const subDto: FilterRequestDto = {
|
|
116
118
|
...newDto,
|
|
117
119
|
entity_type: subEntityType,
|
|
@@ -119,42 +121,48 @@ export class FilterService {
|
|
|
119
121
|
savedFilterCode: null, // already merged
|
|
120
122
|
attributeFilter: [],
|
|
121
123
|
};
|
|
122
|
-
|
|
124
|
+
|
|
123
125
|
const subResult = await this.applyFilter(subDto);
|
|
124
126
|
const subEntityIds = subResult.data.entity_list.map((row) => row.id);
|
|
125
|
-
|
|
126
|
-
console.log(
|
|
127
|
-
|
|
127
|
+
|
|
128
|
+
console.log(
|
|
129
|
+
`🧩 [FilterService] Sub-entity ${subEntityType} returned IDs:`,
|
|
130
|
+
subEntityIds,
|
|
131
|
+
);
|
|
132
|
+
|
|
128
133
|
if (!subEntityIds.length) {
|
|
129
|
-
console.log(
|
|
134
|
+
console.log(
|
|
135
|
+
`ℹ️ [FilterService] No records for sub-entity ${subEntityType}, returning empty result`,
|
|
136
|
+
);
|
|
130
137
|
return {
|
|
131
138
|
success: true,
|
|
132
139
|
data: { entity_tabs: [], entity_list: [], pagination: {} },
|
|
133
140
|
};
|
|
134
141
|
}
|
|
135
|
-
|
|
142
|
+
|
|
136
143
|
const relatedIds = await this.entityRelationService.getRelatedEntityIds(
|
|
137
144
|
entity_type,
|
|
138
145
|
subEntityType,
|
|
139
146
|
subEntityIds,
|
|
140
147
|
dto.loggedInUser.organization_id,
|
|
141
148
|
);
|
|
142
|
-
|
|
149
|
+
|
|
143
150
|
intersectionIds =
|
|
144
151
|
intersectionIds === null
|
|
145
152
|
? relatedIds
|
|
146
153
|
: intersectionIds.filter((id) => relatedIds.includes(id));
|
|
147
|
-
|
|
148
154
|
|
|
149
155
|
if (intersectionIds.length === 0) {
|
|
150
|
-
console.log(
|
|
156
|
+
console.log(
|
|
157
|
+
'🚫 [FilterService] No intersection IDs left, returning empty result',
|
|
158
|
+
);
|
|
151
159
|
return {
|
|
152
160
|
success: true,
|
|
153
161
|
data: { entity_tabs: [], entity_list: [], pagination: {} },
|
|
154
162
|
};
|
|
155
163
|
}
|
|
156
164
|
}
|
|
157
|
-
|
|
165
|
+
|
|
158
166
|
// 🔹 Step 4: Call applyFilter for main entity
|
|
159
167
|
const mainFilters = grouped[entity_type] || [];
|
|
160
168
|
const mainDto: FilterRequestDto = {
|
|
@@ -163,7 +171,7 @@ export class FilterService {
|
|
|
163
171
|
savedFilterCode: null,
|
|
164
172
|
attributeFilter: [],
|
|
165
173
|
};
|
|
166
|
-
|
|
174
|
+
|
|
167
175
|
if (intersectionIds && intersectionIds.length > 0) {
|
|
168
176
|
(mainDto.quickFilter ??= []).push({
|
|
169
177
|
filter_attribute: 'id',
|
|
@@ -172,10 +180,10 @@ export class FilterService {
|
|
|
172
180
|
filter_entity_type: entity_type,
|
|
173
181
|
});
|
|
174
182
|
}
|
|
175
|
-
|
|
176
|
-
return this.applyFilter(mainDto);
|
|
183
|
+
|
|
184
|
+
return await this.applyFilter(mainDto);
|
|
177
185
|
}
|
|
178
|
-
|
|
186
|
+
|
|
179
187
|
async applyFilter(dto: FilterRequestDto) {
|
|
180
188
|
const {
|
|
181
189
|
entity_type,
|
|
@@ -190,7 +198,7 @@ export class FilterService {
|
|
|
190
198
|
customLevelId,
|
|
191
199
|
customAppCode,
|
|
192
200
|
} = dto;
|
|
193
|
-
|
|
201
|
+
|
|
194
202
|
// abstract user details
|
|
195
203
|
const {
|
|
196
204
|
level_type,
|
|
@@ -199,25 +207,25 @@ export class FilterService {
|
|
|
199
207
|
appcode,
|
|
200
208
|
organization_id,
|
|
201
209
|
} = loggedInUser || {};
|
|
202
|
-
|
|
210
|
+
|
|
203
211
|
// Fetch meta from entity table service
|
|
204
212
|
const entityMeta = await this.entityMasterService.getEntityData(
|
|
205
213
|
entity_type,
|
|
206
214
|
loggedInUser,
|
|
207
215
|
);
|
|
208
216
|
const tableName = entityMeta?.data_source; // data_source is the table name
|
|
209
|
-
|
|
217
|
+
|
|
210
218
|
if (!tableName) {
|
|
211
219
|
console.error(`❌ [FilterService] Invalid entity_type: ${entity_type}`);
|
|
212
220
|
throw new BadRequestException(`Invalid entity_type: ${entity_type}`);
|
|
213
221
|
}
|
|
214
|
-
|
|
222
|
+
|
|
215
223
|
const getAttributeColumnMeta =
|
|
216
224
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
217
225
|
entity_type,
|
|
218
226
|
loggedInUser,
|
|
219
227
|
);
|
|
220
|
-
|
|
228
|
+
|
|
221
229
|
const attributeMetaMap = getAttributeColumnMeta.reduce(
|
|
222
230
|
(acc, attr) => {
|
|
223
231
|
acc[attr.attribute_key] = attr;
|
|
@@ -225,7 +233,7 @@ export class FilterService {
|
|
|
225
233
|
},
|
|
226
234
|
{} as Record<string, any>,
|
|
227
235
|
);
|
|
228
|
-
|
|
236
|
+
|
|
229
237
|
// Get and parse saved filters
|
|
230
238
|
const savedFilters = await this.getSavedFilters(
|
|
231
239
|
savedFilterCode ?? undefined,
|
|
@@ -247,11 +255,10 @@ export class FilterService {
|
|
|
247
255
|
(f) => f.filter_value != null && f.filter_value !== '',
|
|
248
256
|
),
|
|
249
257
|
];
|
|
250
|
-
|
|
251
|
-
|
|
258
|
+
|
|
252
259
|
// Build where clauses
|
|
253
260
|
const baseWhere = this.buildWhereClauses(baseFilters, attributeMetaMap);
|
|
254
|
-
|
|
261
|
+
|
|
255
262
|
// check level_id and level_type
|
|
256
263
|
if (
|
|
257
264
|
entity_type != 'ORGP' &&
|
|
@@ -267,20 +274,25 @@ export class FilterService {
|
|
|
267
274
|
params: { organization_id, level_type, level_id },
|
|
268
275
|
});
|
|
269
276
|
}
|
|
270
|
-
|
|
277
|
+
|
|
271
278
|
if (customLevelType && customLevelId && customAppCode) {
|
|
272
279
|
baseWhere.push({
|
|
273
280
|
query:
|
|
274
281
|
'e.organization_id = :organization_id AND e.level_type = :customLevelType AND e.level_id = :customLevelId AND e.appcode = :customAppCode',
|
|
275
|
-
params: {
|
|
282
|
+
params: {
|
|
283
|
+
organization_id,
|
|
284
|
+
customLevelType,
|
|
285
|
+
customLevelId,
|
|
286
|
+
customAppCode,
|
|
287
|
+
},
|
|
276
288
|
});
|
|
277
289
|
}
|
|
278
|
-
|
|
290
|
+
|
|
279
291
|
// Handle queryParams filters
|
|
280
292
|
if (queryParams) {
|
|
281
293
|
Object.entries(queryParams).forEach(([key, value]) => {
|
|
282
294
|
if (!value) return;
|
|
283
|
-
|
|
295
|
+
|
|
284
296
|
if (key === 'attributeName' && queryParams['attributeValue']) {
|
|
285
297
|
const attrName = value;
|
|
286
298
|
const attrValue = queryParams['attributeValue'];
|
|
@@ -296,9 +308,9 @@ export class FilterService {
|
|
|
296
308
|
}
|
|
297
309
|
});
|
|
298
310
|
}
|
|
299
|
-
|
|
311
|
+
|
|
300
312
|
console.log('🟠 [FilterService] Constructed baseWhere clauses:', baseWhere);
|
|
301
|
-
|
|
313
|
+
|
|
302
314
|
// layout preference query
|
|
303
315
|
const layoutPreference = await this.dataSource.query(
|
|
304
316
|
`SELECT mapped_json
|
|
@@ -306,11 +318,11 @@ export class FilterService {
|
|
|
306
318
|
WHERE user_id = ? AND mapped_entity_type = ? AND mapped_level_id = ? AND mapped_level_type = ? AND type = 'layout'`,
|
|
307
319
|
[user_id, entity_type, level_id, level_type],
|
|
308
320
|
);
|
|
309
|
-
|
|
321
|
+
|
|
310
322
|
// Extract layout preference
|
|
311
323
|
const layout = layoutPreference?.[0]?.mapped_json?.quick_tab || {};
|
|
312
324
|
const showList = layout?.show_list?.map((val) => val.toLowerCase()) || [];
|
|
313
|
-
|
|
325
|
+
|
|
314
326
|
let allTabs;
|
|
315
327
|
if (layout.attribute) {
|
|
316
328
|
allTabs = await this.gettab_value_counts(
|
|
@@ -327,22 +339,22 @@ export class FilterService {
|
|
|
327
339
|
}
|
|
328
340
|
|
|
329
341
|
let filteredTabs;
|
|
330
|
-
|
|
342
|
+
|
|
331
343
|
if (showList?.length > 0) {
|
|
332
344
|
const isAllNeeded = layout?.isAllSelected && !showList.includes('all');
|
|
333
345
|
if (isAllNeeded) showList.push('all');
|
|
334
|
-
|
|
346
|
+
|
|
335
347
|
filteredTabs = allTabs.filter((tab) =>
|
|
336
348
|
showList.includes(tab.tab_value.toLowerCase()),
|
|
337
349
|
);
|
|
338
|
-
|
|
350
|
+
|
|
339
351
|
const allTab = filteredTabs.find(
|
|
340
352
|
(tab) => tab.tab_value?.toLowerCase() === 'all',
|
|
341
353
|
);
|
|
342
354
|
filteredTabs = filteredTabs.filter(
|
|
343
355
|
(tab) => tab.tab_value?.toLowerCase() !== 'all',
|
|
344
356
|
);
|
|
345
|
-
|
|
357
|
+
|
|
346
358
|
// SORTING LOGIC
|
|
347
359
|
if (layout.sorting === 'asc') {
|
|
348
360
|
filteredTabs.sort((a, b) =>
|
|
@@ -366,9 +378,9 @@ export class FilterService {
|
|
|
366
378
|
return aIndex - bIndex;
|
|
367
379
|
});
|
|
368
380
|
}
|
|
369
|
-
|
|
381
|
+
|
|
370
382
|
if (allTab) filteredTabs.unshift(allTab);
|
|
371
|
-
|
|
383
|
+
|
|
372
384
|
if (layout?.isCombineOther) {
|
|
373
385
|
const originalAllTab = allTabs.find(
|
|
374
386
|
(tab) => tab.tab_value.toLowerCase() === 'all',
|
|
@@ -377,7 +389,7 @@ export class FilterService {
|
|
|
377
389
|
const knownTabCountSum = filteredTabs
|
|
378
390
|
.filter((tab) => tab.tab_value.toLowerCase() !== 'all')
|
|
379
391
|
.reduce((acc, tab) => acc + tab.tab_value_count, 0);
|
|
380
|
-
|
|
392
|
+
|
|
381
393
|
const othersCount = allCount - knownTabCountSum;
|
|
382
394
|
filteredTabs.push({
|
|
383
395
|
tab_value: 'OTHERS',
|
|
@@ -387,14 +399,13 @@ export class FilterService {
|
|
|
387
399
|
} else {
|
|
388
400
|
filteredTabs = allTabs;
|
|
389
401
|
}
|
|
390
|
-
|
|
391
|
-
|
|
402
|
+
|
|
392
403
|
const dataWhere = [...baseWhere];
|
|
393
|
-
|
|
404
|
+
|
|
394
405
|
if (tabs?.columnName && tabs?.value) {
|
|
395
406
|
const tabAttrMeta = attributeMetaMap[tabs.columnName];
|
|
396
407
|
const tabValue = tabs.value.toLowerCase();
|
|
397
|
-
|
|
408
|
+
|
|
398
409
|
if (tabValue === 'others') {
|
|
399
410
|
const valuesToExclude = showList.filter((v) => v !== 'all');
|
|
400
411
|
if (valuesToExclude.length > 0) {
|
|
@@ -426,7 +437,7 @@ export class FilterService {
|
|
|
426
437
|
tabs.value,
|
|
427
438
|
entity_type,
|
|
428
439
|
);
|
|
429
|
-
|
|
440
|
+
|
|
430
441
|
if (resolvedId) {
|
|
431
442
|
const tabCondition = this.buildCondition(
|
|
432
443
|
{
|
|
@@ -441,53 +452,68 @@ export class FilterService {
|
|
|
441
452
|
}
|
|
442
453
|
}
|
|
443
454
|
}
|
|
444
|
-
|
|
445
|
-
const qb = this.dataSource
|
|
455
|
+
|
|
456
|
+
const qb = this.dataSource
|
|
457
|
+
.createQueryBuilder()
|
|
458
|
+
.select('e.*')
|
|
459
|
+
.from(tableName, 'e');
|
|
446
460
|
dataWhere.forEach((clause) => qb.andWhere(clause.query, clause.params));
|
|
447
|
-
|
|
461
|
+
|
|
448
462
|
if (layoutPreference && layoutPreference[0]?.mapped_json?.sorting) {
|
|
449
463
|
if (Array.isArray(layoutPreference[0]?.mapped_json?.sorting?.tabs)) {
|
|
450
|
-
const preferenceTabArray =
|
|
464
|
+
const preferenceTabArray =
|
|
465
|
+
layoutPreference[0]?.mapped_json?.sorting?.tabs;
|
|
451
466
|
const tabFilter = preferenceTabArray.find(
|
|
452
467
|
(tabData) => tabData.tab_name === tabs?.value,
|
|
453
468
|
);
|
|
454
469
|
tabFilter?.sortby.forEach(({ column, order }) => {
|
|
455
|
-
qb.addOrderBy(
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
qb.addOrderBy(`e.${column}`, order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC');
|
|
470
|
+
qb.addOrderBy(
|
|
471
|
+
`e.${column}`,
|
|
472
|
+
order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC',
|
|
473
|
+
);
|
|
460
474
|
});
|
|
475
|
+
} else if (
|
|
476
|
+
Array.isArray(layoutPreference[0]?.mapped_json?.sorting?.sortby)
|
|
477
|
+
) {
|
|
478
|
+
layoutPreference[0]?.mapped_json?.sorting?.sortby?.forEach(
|
|
479
|
+
({ column, order }) => {
|
|
480
|
+
qb.addOrderBy(
|
|
481
|
+
`e.${column}`,
|
|
482
|
+
order?.toUpperCase() === 'DSC' ? 'DESC' : 'ASC',
|
|
483
|
+
);
|
|
484
|
+
},
|
|
485
|
+
);
|
|
461
486
|
}
|
|
462
487
|
}
|
|
463
|
-
|
|
488
|
+
|
|
464
489
|
qb.addOrderBy('e.created_date', 'DESC');
|
|
465
|
-
|
|
490
|
+
|
|
466
491
|
const page = dto.page && dto.page > 0 ? dto.page : 1;
|
|
467
492
|
const size = dto.size && dto.size > 0 ? dto.size : 10;
|
|
468
493
|
qb.skip((page - 1) * size).take(size);
|
|
469
|
-
|
|
494
|
+
|
|
470
495
|
const entity_list = await qb.getRawMany();
|
|
471
|
-
|
|
496
|
+
|
|
472
497
|
console.log(`📦 [FilterService] Fetched ${entity_list.length} records`);
|
|
473
|
-
|
|
498
|
+
|
|
474
499
|
const dateAttributes = Object.entries(attributeMetaMap)
|
|
475
500
|
.filter(([_, attr]) => attr.data_type === 'date')
|
|
476
501
|
.map(([key]) => key);
|
|
477
|
-
|
|
502
|
+
|
|
478
503
|
const formatDate = (dateStr: string | null): string | null =>
|
|
479
504
|
dateStr ? moment(dateStr).format('DD-MM-YYYY') : '';
|
|
480
|
-
|
|
505
|
+
|
|
481
506
|
const formatDatesInRow = (row: any): any => {
|
|
482
507
|
const formattedRow = { ...row };
|
|
483
508
|
for (const key of dateAttributes) {
|
|
484
|
-
if (formattedRow[key])
|
|
509
|
+
if (formattedRow[key])
|
|
510
|
+
formattedRow[key] = formatDate(formattedRow[key]);
|
|
485
511
|
}
|
|
486
512
|
return formattedRow;
|
|
487
513
|
};
|
|
488
|
-
|
|
514
|
+
|
|
489
515
|
const formattedEntityList = entity_list.map(formatDatesInRow);
|
|
490
|
-
|
|
516
|
+
|
|
491
517
|
const resolvedEntityList = await Promise.all(
|
|
492
518
|
formattedEntityList.map((row) =>
|
|
493
519
|
this.resolverService.getResolvedData(loggedInUser, row, entity_type),
|
|
@@ -497,7 +523,7 @@ export class FilterService {
|
|
|
497
523
|
const resolvedTabs = await Promise.all(
|
|
498
524
|
filteredTabs.map(async (tab) => {
|
|
499
525
|
const tabAttrKey = layout?.attribute || tabs?.columnName;
|
|
500
|
-
|
|
526
|
+
|
|
501
527
|
if (
|
|
502
528
|
!tabAttrKey ||
|
|
503
529
|
tab.tab_value?.toLowerCase() === 'all' ||
|
|
@@ -505,29 +531,30 @@ export class FilterService {
|
|
|
505
531
|
) {
|
|
506
532
|
return tab;
|
|
507
533
|
}
|
|
508
|
-
|
|
534
|
+
|
|
509
535
|
const resolvedVal = await this.resolverService.getResolvedValue(
|
|
510
536
|
loggedInUser,
|
|
511
537
|
tabAttrKey,
|
|
512
538
|
tab.tab_value,
|
|
513
539
|
entity_type,
|
|
514
540
|
);
|
|
515
|
-
|
|
541
|
+
|
|
516
542
|
return { ...tab, tab_value: resolvedVal ?? tab.tab_value };
|
|
517
543
|
}),
|
|
518
544
|
);
|
|
519
|
-
|
|
520
|
-
|
|
545
|
+
|
|
521
546
|
const countQb = this.dataSource
|
|
522
547
|
.createQueryBuilder()
|
|
523
548
|
.select('COUNT(*)', 'count')
|
|
524
549
|
.from(tableName, 'e');
|
|
525
|
-
dataWhere.forEach((clause) =>
|
|
550
|
+
dataWhere.forEach((clause) =>
|
|
551
|
+
countQb.andWhere(clause.query, clause.params),
|
|
552
|
+
);
|
|
526
553
|
const countResult = await countQb.getRawOne();
|
|
527
554
|
const total = parseInt(countResult.count, 10);
|
|
528
|
-
|
|
555
|
+
|
|
529
556
|
console.log('📊 [FilterService] Returning final result with total:', total);
|
|
530
|
-
|
|
557
|
+
|
|
531
558
|
return {
|
|
532
559
|
success: true,
|
|
533
560
|
data: {
|
|
@@ -544,7 +571,7 @@ export class FilterService {
|
|
|
544
571
|
},
|
|
545
572
|
};
|
|
546
573
|
}
|
|
547
|
-
|
|
574
|
+
|
|
548
575
|
private parseFilters(raw: any, isSingle = false): any[] {
|
|
549
576
|
if (!raw) return [];
|
|
550
577
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable, Logger, LoggerService } from '@nestjs/common';
|
|
2
2
|
import { FieldMapperRepository } from '../repository/field-mapper.repository';
|
|
3
3
|
import { FieldMapperDto } from '../dto/field-mapper.dto';
|
|
4
4
|
import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
|
|
@@ -7,6 +7,7 @@ import { FieldLovsRepository } from '../repository/field-lovs.repository';
|
|
|
7
7
|
import { DataSource } from 'typeorm';
|
|
8
8
|
import { FilterService } from 'src/module/filter/service/filter.service';
|
|
9
9
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
10
|
+
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
10
11
|
|
|
11
12
|
@Injectable()
|
|
12
13
|
export class FieldMapperService extends EntityServiceImpl {
|
|
@@ -15,6 +16,7 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
15
16
|
private readonly fieldLovsRepository: FieldLovsRepository,
|
|
16
17
|
private readonly datasource: DataSource,
|
|
17
18
|
private readonly filterService: FilterService,
|
|
19
|
+
@Inject() protected readonly loggingService: LoggingService,
|
|
18
20
|
) {
|
|
19
21
|
super();
|
|
20
22
|
}
|
|
@@ -67,7 +69,10 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
67
69
|
|
|
68
70
|
async getMapperFields(mapperId: number, mapper_entity_type: string) {
|
|
69
71
|
let fieldMappers =
|
|
70
|
-
await this.fieldMapperRepository.findByMapperIdAndMapperEntityType(
|
|
72
|
+
await this.fieldMapperRepository.findByMapperIdAndMapperEntityType(
|
|
73
|
+
mapperId,
|
|
74
|
+
mapper_entity_type,
|
|
75
|
+
);
|
|
71
76
|
const fieldMapperDtos = fieldMappers as unknown as FieldMapperDto[];
|
|
72
77
|
for (const fieldMapper of fieldMapperDtos) {
|
|
73
78
|
fieldMapper.field_lovs =
|
|
@@ -134,9 +139,16 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
134
139
|
|
|
135
140
|
const targetEntityIds = relations.map((r) => r.target_entity_id);
|
|
136
141
|
|
|
142
|
+
this.loggingService.log(
|
|
143
|
+
'package',
|
|
144
|
+
'fieldMapperService',
|
|
145
|
+
'targetEntityIds',
|
|
146
|
+
targetEntityIds,
|
|
147
|
+
);
|
|
148
|
+
|
|
137
149
|
if (targetEntityIds.length > 0) {
|
|
138
150
|
if (filterCode && filterCode !== 'default') {
|
|
139
|
-
|
|
151
|
+
let filterResponse =
|
|
140
152
|
await this.filterService.applyFilterWrapper({
|
|
141
153
|
entity_type: entityType,
|
|
142
154
|
savedFilterCode: filterCode,
|
|
@@ -152,6 +164,16 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
152
164
|
loggedInUser: userData,
|
|
153
165
|
queryParams: {},
|
|
154
166
|
});
|
|
167
|
+
|
|
168
|
+
this.loggingService.log(
|
|
169
|
+
'package',
|
|
170
|
+
'fieldMapperService',
|
|
171
|
+
'filterResponse',
|
|
172
|
+
`${filterResponse}`,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
inMemory[entityType][filterCode] =
|
|
176
|
+
filterResponse?.data?.entity_list[0];
|
|
155
177
|
} else {
|
|
156
178
|
const firstId = targetEntityIds[0];
|
|
157
179
|
inMemory[entityType][filterCode] =
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Controller,
|
|
4
|
+
Get,
|
|
5
|
+
Param,
|
|
6
|
+
Query,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { WorkflowAutomationEngineService } from 'src/module/workflow-automation/service/workflow-automation-engine.service';
|
|
9
|
+
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
10
|
+
import { EntityMasterService } from '../service/entity-master.service';
|
|
11
|
+
import { EntityServiceImpl } from '../service/entity-service-impl.service';
|
|
12
|
+
|
|
13
|
+
@Controller('entity/public')
|
|
14
|
+
export class EntityPublicController {
|
|
15
|
+
constructor(
|
|
16
|
+
private entityService: EntityServiceImpl,
|
|
17
|
+
private reflectionHelper: ReflectionHelper,
|
|
18
|
+
private entityMasterService: EntityMasterService,
|
|
19
|
+
private readonly workflowAutomationEngineService: WorkflowAutomationEngineService,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
@Get('getById/:id')
|
|
23
|
+
async getPublicById(
|
|
24
|
+
@Param('id') id: number,
|
|
25
|
+
@Query() queryParams: Record<string, string>,
|
|
26
|
+
) {
|
|
27
|
+
const {
|
|
28
|
+
entity_type: entityType,
|
|
29
|
+
loggedInUser: loggedInUserParam,
|
|
30
|
+
...params
|
|
31
|
+
} = queryParams;
|
|
32
|
+
|
|
33
|
+
if (!entityType) {
|
|
34
|
+
throw new BadRequestException(
|
|
35
|
+
'Query parameter "entity_type" is required',
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Default user object (if organization_id or appcode is needed in service)
|
|
40
|
+
let loggedInUser: any = {};
|
|
41
|
+
|
|
42
|
+
if (typeof loggedInUserParam === 'string') {
|
|
43
|
+
try {
|
|
44
|
+
loggedInUser = JSON.parse(loggedInUserParam);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
loggedInUser = {};
|
|
47
|
+
}
|
|
48
|
+
} else if (
|
|
49
|
+
typeof loggedInUserParam === 'object' &&
|
|
50
|
+
loggedInUserParam !== null
|
|
51
|
+
) {
|
|
52
|
+
loggedInUser = loggedInUserParam;
|
|
53
|
+
} else {
|
|
54
|
+
loggedInUser = {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!entityType) {
|
|
58
|
+
throw new BadRequestException(
|
|
59
|
+
'Query parameter "entity_type" is required',
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
63
|
+
entityType,
|
|
64
|
+
loggedInUser,
|
|
65
|
+
);
|
|
66
|
+
const entityService =
|
|
67
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
68
|
+
entityMaster.entity_service,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (entityService) {
|
|
72
|
+
return await entityService.getEntityData(entityType, id, loggedInUser);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -59,6 +59,7 @@ import { CommonService } from './service/common.service';
|
|
|
59
59
|
import { EntityMasterRepository } from './repository/entity-master.repository';
|
|
60
60
|
import { EntityMasterController } from './controller/entity-master.controller';
|
|
61
61
|
import { WorkflowAutomationModule } from '../workflow-automation/workflow-automation.module';
|
|
62
|
+
import { EntityPublicController } from './controller/entity.public.controller';
|
|
62
63
|
|
|
63
64
|
@Module({
|
|
64
65
|
imports: [
|
|
@@ -78,7 +79,7 @@ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automa
|
|
|
78
79
|
forwardRef(() => ListMasterModule),
|
|
79
80
|
forwardRef(() => FilterModule),
|
|
80
81
|
UtilsModule,
|
|
81
|
-
WorkflowAutomationModule
|
|
82
|
+
WorkflowAutomationModule,
|
|
82
83
|
],
|
|
83
84
|
providers: [
|
|
84
85
|
EntityMasterService,
|
|
@@ -138,7 +139,7 @@ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automa
|
|
|
138
139
|
ResolverService,
|
|
139
140
|
EntityDynamicService,
|
|
140
141
|
'CommonService',
|
|
141
|
-
'EntityRelationService'
|
|
142
|
+
'EntityRelationService',
|
|
142
143
|
],
|
|
143
144
|
controllers: [
|
|
144
145
|
EntityController,
|
|
@@ -151,6 +152,7 @@ import { WorkflowAutomationModule } from '../workflow-automation/workflow-automa
|
|
|
151
152
|
EntityDynamicController,
|
|
152
153
|
EntityRelationController,
|
|
153
154
|
EntityMasterController,
|
|
155
|
+
EntityPublicController,
|
|
154
156
|
],
|
|
155
157
|
})
|
|
156
158
|
export class EntityModule {}
|