rez_core 2.2.112 → 2.2.113
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/meta/service/entity-dynamic.service.d.ts +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +29 -2
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/service/entity-dynamic.service.ts +44 -2
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { STATUS_ACTIVE } from 'src/constant/global.constant';
|
|
2
3
|
import { DataSource } from 'typeorm';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
@@ -8,7 +9,7 @@ export class EntityDynamicService {
|
|
|
8
9
|
// -----------------------------
|
|
9
10
|
async createEntity(
|
|
10
11
|
entityType: string,
|
|
11
|
-
|
|
12
|
+
entityData: Record<string, any>,
|
|
12
13
|
loggedInUser: any,
|
|
13
14
|
): Promise<any> {
|
|
14
15
|
const organizationId = loggedInUser.organization_id;
|
|
@@ -19,12 +20,53 @@ export class EntityDynamicService {
|
|
|
19
20
|
organizationId,
|
|
20
21
|
);
|
|
21
22
|
|
|
23
|
+
const statusList = await this.dataSource.query(
|
|
24
|
+
`SELECT id FROM cr_list_master_items WHERE code = ? AND organization_id = ?`,
|
|
25
|
+
[STATUS_ACTIVE, loggedInUser?.organization_id || 0],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// if (!entityData.code && loggedInUser) {
|
|
29
|
+
// let maxSeqNo = await this.getMaxSequenceNumber(
|
|
30
|
+
// entityData.entity_type,
|
|
31
|
+
// entityData.parent_id,
|
|
32
|
+
// entityData.parent_type,
|
|
33
|
+
// loggedInUser,
|
|
34
|
+
// );
|
|
35
|
+
// maxSeqNo = Number(maxSeqNo) + 1;
|
|
36
|
+
// entityData.code = entityData.entity_type + maxSeqNo;
|
|
37
|
+
// }
|
|
38
|
+
|
|
39
|
+
entityData.created_date = new Date();
|
|
40
|
+
if (loggedInUser) {
|
|
41
|
+
entityData.created_by = loggedInUser.id;
|
|
42
|
+
if (!entityData.organization_id)
|
|
43
|
+
entityData.organization_id = loggedInUser.organization_id;
|
|
44
|
+
if (!entityData.enterprise_id)
|
|
45
|
+
entityData.enterprise_id = loggedInUser.enterprise_id;
|
|
46
|
+
if (!entityData.level_type)
|
|
47
|
+
entityData.level_type = loggedInUser.level_type;
|
|
48
|
+
if (!entityData.level_id) entityData.level_id = loggedInUser.level_id;
|
|
49
|
+
if (!entityData.status) entityData.status = statusList[0].id;
|
|
50
|
+
}
|
|
51
|
+
const bypassColumn = [
|
|
52
|
+
'created_date',
|
|
53
|
+
'created_by',
|
|
54
|
+
'organization_id',
|
|
55
|
+
'enterprise_id',
|
|
56
|
+
'level_type',
|
|
57
|
+
'level_id',
|
|
58
|
+
'status',
|
|
59
|
+
'entity_type',
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
validAttributes.push(...bypassColumn);
|
|
63
|
+
|
|
22
64
|
const columns: string[] = [];
|
|
23
65
|
const values: any[] = [];
|
|
24
66
|
|
|
25
67
|
validAttributes.forEach((attr) => {
|
|
26
68
|
columns.push(attr);
|
|
27
|
-
values.push(attr in
|
|
69
|
+
values.push(attr in entityData ? entityData[attr] : null);
|
|
28
70
|
});
|
|
29
71
|
|
|
30
72
|
const placeholders = columns.map(() => '?').join(', ');
|