rez_core 4.0.207 → 4.0.209
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/package.json
CHANGED
|
@@ -39,29 +39,56 @@ export class EntityRelationService extends EntityServiceImpl {
|
|
|
39
39
|
|
|
40
40
|
return relations;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
async getRelatedEntityIds(
|
|
44
|
-
sourceEntity: string,
|
|
45
|
-
targetEntity: string,
|
|
46
|
-
targetIds: number[],
|
|
44
|
+
sourceEntity: string,
|
|
45
|
+
targetEntity: string,
|
|
46
|
+
targetIds: number[],
|
|
47
47
|
orgId: number,
|
|
48
48
|
): Promise<number[]> {
|
|
49
|
-
|
|
50
|
-
if (!targetIds.length) return [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
|
|
50
|
+
if (!targetIds.length) return [];
|
|
51
|
+
|
|
52
|
+
// correct starting index
|
|
53
|
+
let paramIndex = 1;
|
|
54
|
+
|
|
55
|
+
const params: any[] = [];
|
|
56
|
+
|
|
57
|
+
// $1
|
|
58
|
+
params.push(String(sourceEntity));
|
|
59
|
+
paramIndex++;
|
|
60
|
+
|
|
61
|
+
// $2
|
|
62
|
+
params.push(String(targetEntity));
|
|
63
|
+
paramIndex++;
|
|
64
|
+
|
|
65
|
+
// Build placeholders for targetIds → start from $3
|
|
66
|
+
const idPlaceholders = targetIds
|
|
67
|
+
.map((id) => {
|
|
68
|
+
params.push(String(id));
|
|
69
|
+
const placeholder = `$${paramIndex}`;
|
|
70
|
+
paramIndex++;
|
|
71
|
+
return placeholder;
|
|
72
|
+
})
|
|
73
|
+
.join(", ");
|
|
74
|
+
|
|
75
|
+
// Now orgId (final param)
|
|
76
|
+
params.push(String(orgId));
|
|
77
|
+
const orgPlaceholder = `$${paramIndex}`;
|
|
78
|
+
|
|
79
|
+
// Final SQL
|
|
80
|
+
const sql = `
|
|
81
|
+
SELECT DISTINCT source_entity_id
|
|
82
|
+
FROM frm_entity_relation_data
|
|
83
|
+
WHERE source_entity_type = $1
|
|
84
|
+
AND target_entity_type = $2
|
|
85
|
+
AND target_entity_id IN (${idPlaceholders})
|
|
86
|
+
AND organization_id = ${orgPlaceholder}
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
const rows = await this.dataSource.query(sql, params);
|
|
90
|
+
|
|
91
|
+
return rows.map((r: any) => Number(r.source_entity_id));
|
|
65
92
|
}
|
|
66
93
|
|
|
67
94
|
|