rez_core 4.0.207 → 4.0.208
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,49 @@ 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
|
+
let paramIndex = 1;
|
|
53
|
+
|
|
54
|
+
// first three params
|
|
55
|
+
const params: any[] = [
|
|
56
|
+
String(sourceEntity), // $1
|
|
57
|
+
String(targetEntity), // $2
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
// build placeholders for targetIds
|
|
61
|
+
const idPlaceholders = targetIds
|
|
62
|
+
.map((id) => {
|
|
63
|
+
params.push(String(id));
|
|
64
|
+
paramIndex++;
|
|
65
|
+
return `$${paramIndex}`;
|
|
66
|
+
})
|
|
67
|
+
.join(", ");
|
|
68
|
+
|
|
69
|
+
// now orgId
|
|
70
|
+
params.push(String(orgId));
|
|
71
|
+
paramIndex++;
|
|
72
|
+
|
|
73
|
+
const sql = `
|
|
74
|
+
SELECT DISTINCT source_entity_id
|
|
75
|
+
FROM frm_entity_relation_data
|
|
76
|
+
WHERE source_entity_type = $1
|
|
77
|
+
AND target_entity_type = $2
|
|
78
|
+
AND target_entity_id IN (${idPlaceholders})
|
|
79
|
+
AND organization_id = $${paramIndex}
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
const rows = await this.dataSource.query(sql, params);
|
|
83
|
+
|
|
84
|
+
return rows.map((r: any) => Number(r.source_entity_id));
|
|
65
85
|
}
|
|
66
86
|
|
|
67
87
|
|