rez_core 5.0.86 → 5.0.88
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/.vscode/extensions.json +5 -0
- package/dist/module/enterprise/repository/school.repository.d.ts +3 -3
- package/dist/module/enterprise/repository/school.repository.js +56 -70
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/mapper/service/field-mapper.service.d.ts +1 -3
- package/dist/module/mapper/service/field-mapper.service.js +10 -10
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/meta/controller/meta.controller.d.ts +4 -1
- package/dist/module/meta/repository/entity-attribute-update.repository.d.ts +5 -3
- package/dist/module/meta/repository/entity-attribute-update.repository.js +19 -13
- package/dist/module/meta/repository/entity-attribute-update.repository.js.map +1 -1
- package/dist/module/meta/repository/entity-master.repository.d.ts +8 -4
- package/dist/module/meta/repository/entity-master.repository.js +15 -12
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +5 -2
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +4 -1
- package/dist/module/meta/service/resolver.service.d.ts +5 -3
- package/dist/module/meta/service/resolver.service.js +25 -34
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +1 -1
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +4 -7
- package/dist/module/user/service/login.service.js +24 -20
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +8 -5
- package/dist/module/user/service/user-session.service.js +45 -24
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/workflow/controller/action-template-mapping.controller.d.ts +1 -1
- package/dist/module/workflow/repository/stage.repository.js.map +1 -1
- package/dist/module/workflow/service/action-template-mapping.service.d.ts +3 -4
- package/dist/module/workflow/service/action-template-mapping.service.js +43 -33
- package/dist/module/workflow/service/action-template-mapping.service.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/enterprise/repository/school.repository.ts +68 -74
- package/src/module/mapper/service/field-mapper.service.ts +11 -13
- package/src/module/meta/repository/entity-attribute-update.repository.ts +31 -27
- package/src/module/meta/repository/entity-master.repository.ts +12 -14
- package/src/module/meta/service/entity-dynamic.service.ts +5 -38
- package/src/module/meta/service/resolver.service.ts +23 -47
- package/src/module/module/repository/menu.repository.ts +1 -1
- package/src/module/user/service/login.service.ts +26 -26
- package/src/module/user/service/user-session.service.ts +41 -32
- package/src/module/workflow/repository/stage.repository.ts +0 -12
- package/src/module/workflow/service/action-template-mapping.service.ts +47 -47
- package/src/module/workflow/service/populate-workflow.service.ts +0 -13
- package/src/module/workflow/service/workflow-meta.service.ts +0 -18
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +0 -5
- package/.idea/250218_nodejs_core.iml +0 -12
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
package/package.json
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
// import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { DataSource, Repository } from 'typeorm';
|
|
4
|
-
// import { SchoolData } from '../entity/school.entity';
|
|
5
|
-
import { UserRoleMapping } from 'src/module/user/entity/user-role-mapping.entity';
|
|
6
2
|
import { STATUS_INACTIVE } from 'src/constant/global.constant';
|
|
3
|
+
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
7
4
|
|
|
8
5
|
@Injectable()
|
|
9
6
|
export class SchoolRepository {
|
|
10
|
-
constructor(private readonly
|
|
7
|
+
constructor(private readonly reflectionHelper: ReflectionHelper) {
|
|
8
|
+
}
|
|
11
9
|
|
|
12
10
|
async findAllByOrgId(orgId: number): Promise<any[]> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
|
|
12
|
+
return await schoolRepo.find({
|
|
13
|
+
where: {
|
|
14
|
+
organization_id: orgId,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
async findAllByBrandId(brdId: number): Promise<any[]> {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
|
|
21
|
+
return await schoolRepo.find({
|
|
22
|
+
where: {
|
|
23
|
+
brand_id: brdId,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
async getUserContextDropdown(userId: number, appCode: string, org_id) {
|
|
31
|
-
const userRoleRepo = this.
|
|
29
|
+
const userRoleRepo = this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
32
30
|
|
|
33
31
|
const hasOrgAccess = await userRoleRepo
|
|
34
32
|
.createQueryBuilder('urm')
|
|
@@ -42,19 +40,19 @@ export class SchoolRepository {
|
|
|
42
40
|
currentORGLevel_id = org_id;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.from('frm_list_master_items', 'cli')
|
|
49
|
-
.where('cli.code = :code AND cli.organization_id = :orgId', {
|
|
43
|
+
const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
44
|
+
const resolvedInactiveStatus = await listMasterItemsRepo.findOne({
|
|
45
|
+
where: {
|
|
50
46
|
code: STATUS_INACTIVE,
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
47
|
+
organization_id: org_id,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
54
50
|
|
|
55
51
|
if (hasOrgAccess.length > 0) {
|
|
56
|
-
const
|
|
57
|
-
|
|
52
|
+
const organizationRepo = this.reflectionHelper.getRepoService('OrganizationData');
|
|
53
|
+
|
|
54
|
+
const schools = await organizationRepo
|
|
55
|
+
.createQueryBuilder('org')
|
|
58
56
|
.select([
|
|
59
57
|
'org.id AS org_id',
|
|
60
58
|
'org.name AS org_name',
|
|
@@ -70,14 +68,18 @@ export class SchoolRepository {
|
|
|
70
68
|
'school.location AS school_location',
|
|
71
69
|
'school.status AS school_status',
|
|
72
70
|
])
|
|
73
|
-
|
|
74
|
-
.innerJoin(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
.innerJoin(
|
|
71
|
+
// JOIN brand (on the same table)
|
|
72
|
+
.innerJoin(
|
|
73
|
+
'sso_organization',
|
|
74
|
+
'brn',
|
|
75
|
+
'brn.type = \'BRN\' AND brn.parent_id::varchar = org.id::varchar',
|
|
76
|
+
)
|
|
77
|
+
// JOIN school table
|
|
78
|
+
.innerJoin(
|
|
79
|
+
'sso_school',
|
|
80
|
+
'school',
|
|
81
|
+
'school.brand_id::varchar = brn.id::varchar',
|
|
82
|
+
)
|
|
81
83
|
.where('org.id = :orgId', { orgId: String(currentORGLevel_id) })
|
|
82
84
|
.distinct(true)
|
|
83
85
|
.getRawMany();
|
|
@@ -99,15 +101,12 @@ export class SchoolRepository {
|
|
|
99
101
|
school_status,
|
|
100
102
|
} = row;
|
|
101
103
|
|
|
102
|
-
const orgStatus = await
|
|
103
|
-
|
|
104
|
-
.select('*')
|
|
105
|
-
.from('frm_list_master_items', 'cli')
|
|
106
|
-
.where('cli.id = :id AND cli.organization_id = :orgId', {
|
|
104
|
+
const orgStatus = await listMasterItemsRepo.findOne({
|
|
105
|
+
where: {
|
|
107
106
|
id: org_status,
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
107
|
+
organization_id: org_id,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
111
110
|
|
|
112
111
|
if (!result[org_id]) {
|
|
113
112
|
result[org_id] = {
|
|
@@ -120,15 +119,12 @@ export class SchoolRepository {
|
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
const brandStatus = await
|
|
124
|
-
|
|
125
|
-
.select('*')
|
|
126
|
-
.from('frm_list_master_items', 'cli')
|
|
127
|
-
.where('cli.id = :id AND cli.organization_id = :orgId', {
|
|
122
|
+
const brandStatus = await listMasterItemsRepo.findOne({
|
|
123
|
+
where: {
|
|
128
124
|
id: brand_status,
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
125
|
+
organization_id: org_id,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
132
128
|
|
|
133
129
|
if (!result[org_id].brands[brand_id]) {
|
|
134
130
|
result[org_id].brands[brand_id] = {
|
|
@@ -140,15 +136,12 @@ export class SchoolRepository {
|
|
|
140
136
|
};
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
const schoolStatus = await
|
|
144
|
-
|
|
145
|
-
.select('*')
|
|
146
|
-
.from('frm_list_master_items', 'cli')
|
|
147
|
-
.where('cli.id = :id AND cli.organization_id = :orgId', {
|
|
139
|
+
const schoolStatus = await listMasterItemsRepo.findOne({
|
|
140
|
+
where: {
|
|
148
141
|
id: school_status,
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
142
|
+
organization_id: org_id,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
152
145
|
|
|
153
146
|
const finalSchoolName =
|
|
154
147
|
schoolStatus?.id === resolvedInactiveStatus?.id
|
|
@@ -168,14 +161,12 @@ export class SchoolRepository {
|
|
|
168
161
|
brands: Object.values(org.brands),
|
|
169
162
|
}));
|
|
170
163
|
} else {
|
|
171
|
-
const orgDetails = await this.dataSource.createQueryBuilder();
|
|
172
164
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const orgResult = await orgDetails.getRawOne();
|
|
165
|
+
const orgResult = await organizationRepo.findOne({
|
|
166
|
+
where: {
|
|
167
|
+
id: currentORGLevel_id,
|
|
168
|
+
},
|
|
169
|
+
});
|
|
179
170
|
|
|
180
171
|
return [
|
|
181
172
|
{
|
|
@@ -189,18 +180,21 @@ export class SchoolRepository {
|
|
|
189
180
|
];
|
|
190
181
|
}
|
|
191
182
|
} else {
|
|
192
|
-
|
|
193
|
-
|
|
183
|
+
|
|
184
|
+
const userRoleMappingRepo = this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
185
|
+
|
|
186
|
+
const brnMappings = await userRoleMappingRepo
|
|
187
|
+
.createQueryBuilder('urm')
|
|
194
188
|
.select([
|
|
195
189
|
'brand.id AS brand_id',
|
|
196
190
|
'brand.name AS brand_name',
|
|
197
191
|
'brand.status AS brand_status',
|
|
192
|
+
|
|
198
193
|
'school.id AS school_id',
|
|
199
194
|
'school.name AS school_name',
|
|
200
195
|
'school.location AS school_location',
|
|
201
196
|
'school.status AS school_status',
|
|
202
197
|
])
|
|
203
|
-
.from('sso_user_role_mapping', 'urm')
|
|
204
198
|
.innerJoin('sso_organization', 'brand', 'brand.id = urm.level_id')
|
|
205
199
|
.innerJoin('sso_school', 'school', 'school.brand_id = brand.id')
|
|
206
200
|
.where('urm.user_id = :userId', { userId })
|
|
@@ -209,24 +203,24 @@ export class SchoolRepository {
|
|
|
209
203
|
.distinct(true)
|
|
210
204
|
.getRawMany();
|
|
211
205
|
|
|
212
|
-
const schMappings = await
|
|
213
|
-
.createQueryBuilder()
|
|
206
|
+
const schMappings = await userRoleMappingRepo
|
|
207
|
+
.createQueryBuilder('urm')
|
|
214
208
|
.select([
|
|
215
209
|
'brand.id AS brand_id',
|
|
216
210
|
'brand.name AS brand_name',
|
|
217
211
|
'brand.status AS brand_status',
|
|
212
|
+
|
|
218
213
|
'school.id AS school_id',
|
|
219
214
|
'school.name AS school_name',
|
|
220
215
|
'school.location AS school_location',
|
|
221
216
|
'school.status AS school_status',
|
|
222
217
|
])
|
|
223
|
-
.from('sso_user_role_mapping', 'urm')
|
|
224
218
|
.innerJoin('sso_school', 'school', 'school.id = urm.level_id')
|
|
225
219
|
.innerJoin('sso_organization', 'brand', 'brand.id = school.brand_id')
|
|
226
220
|
.where('urm.user_id = :userId', { userId })
|
|
227
221
|
.andWhere('urm.appcode = :appCode', { appCode })
|
|
228
222
|
.andWhere('urm.level_type = :levelType', { levelType: 'SCH' })
|
|
229
|
-
.distinct(true)
|
|
223
|
+
.distinct(true)
|
|
230
224
|
.getRawMany();
|
|
231
225
|
|
|
232
226
|
const allMappings = [...brnMappings, ...schMappings];
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Inject, Injectable
|
|
1
|
+
import { Inject, Injectable } 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';
|
|
5
5
|
import { UserData } from '../../user/entity/user.entity';
|
|
6
6
|
import { FieldLovsRepository } from '../repository/field-lovs.repository';
|
|
7
|
-
import { DataSource } from 'typeorm';
|
|
8
7
|
import { FilterService } from 'src/module/filter/service/filter.service';
|
|
9
8
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
10
9
|
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
@@ -14,7 +13,6 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
14
13
|
constructor(
|
|
15
14
|
private readonly fieldMapperRepository: FieldMapperRepository,
|
|
16
15
|
private readonly fieldLovsRepository: FieldLovsRepository,
|
|
17
|
-
private readonly datasource: DataSource,
|
|
18
16
|
private readonly filterService: FilterService,
|
|
19
17
|
@Inject() protected readonly loggingService: LoggingService,
|
|
20
18
|
) {
|
|
@@ -139,14 +137,14 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
139
137
|
inMemory[entityType][filterCode] =
|
|
140
138
|
entity_data[field.mapped_entity_type];
|
|
141
139
|
} else {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
);
|
|
140
|
+
const relationDataRepo = this.reflectionHelper.getRepoService('EntityRelationData');
|
|
141
|
+
const relations = await relationDataRepo.find({
|
|
142
|
+
where: {
|
|
143
|
+
source_entity_type: parent_type,
|
|
144
|
+
source_entity_id: parent_id,
|
|
145
|
+
target_entity_type: field.mapped_entity_type,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
150
148
|
|
|
151
149
|
const targetEntityIds = relations.map((r) => r.target_entity_id);
|
|
152
150
|
|
|
@@ -237,8 +235,8 @@ export class FieldMapperService extends EntityServiceImpl {
|
|
|
237
235
|
}
|
|
238
236
|
}
|
|
239
237
|
|
|
240
|
-
|
|
241
|
-
|
|
238
|
+
// ----------------------------------------------------------------
|
|
239
|
+
// LOAD (External → System)
|
|
242
240
|
// ----------------------------------------------------------------
|
|
243
241
|
else if (action === 'LOAD' && inputJson) {
|
|
244
242
|
let value = inputJson[field.source_attribute];
|
|
@@ -1,44 +1,48 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityManager } from 'typeorm';
|
|
3
|
+
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
3
4
|
|
|
4
5
|
@Injectable()
|
|
5
6
|
export class EntityUpdateRepository {
|
|
6
|
-
constructor(private readonly
|
|
7
|
+
constructor(private readonly entityManager: EntityManager,
|
|
8
|
+
private readonly reflectionHelper: ReflectionHelper,
|
|
9
|
+
) {
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
async updateEntityAttribute(entity, config) {
|
|
14
|
+
const { entityType, organization_id } = entity;
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
// 1. Get the table name
|
|
17
|
+
const entityMasterRepo = this.reflectionHelper.getRepoService('EntityMaster');
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
19
|
+
const result = await entityMasterRepo.findOne({
|
|
20
|
+
where: {
|
|
21
|
+
mapped_entity_type: entityType,
|
|
22
|
+
organization_id,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (!result) {
|
|
27
|
+
throw new Error('Entity table not found');
|
|
28
|
+
}
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
const entityTableName = result.db_table_name;
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
// 2. Determine the ID condition
|
|
29
33
|
|
|
30
|
-
const isLead = config.entity_type ===
|
|
31
|
-
const idColumn = isLead ?
|
|
34
|
+
const isLead = config.entity_type === 'LEAD';
|
|
35
|
+
const idColumn = isLead ? 'id' : 'parent_id';
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
// 3. Update using dynamic table name
|
|
34
38
|
|
|
35
|
-
return await this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
return await this.entityManager
|
|
40
|
+
.createQueryBuilder()
|
|
41
|
+
.update(entityTableName)
|
|
42
|
+
.set({ [config.attribute_key]: config.attribute_value })
|
|
43
|
+
.where(`${idColumn} = :id`, { id: entity.id })
|
|
44
|
+
.execute();
|
|
41
45
|
|
|
42
|
-
}
|
|
46
|
+
}
|
|
43
47
|
|
|
44
48
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityMaster } from '../entity/entity-master.entity';
|
|
3
3
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
4
|
-
import { Repository
|
|
4
|
+
import { Repository } from 'typeorm';
|
|
5
5
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
6
|
-
import { EntityRelationService } from '../service/entity-relation.service';
|
|
7
6
|
import { EntityRelation } from '../entity/entity-relation.entity';
|
|
7
|
+
import { AttributeMaster } from '../entity/attribute-master.entity';
|
|
8
8
|
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class EntityMasterRepository {
|
|
11
11
|
constructor(
|
|
12
12
|
@InjectRepository(EntityMaster)
|
|
13
13
|
private readonly entityMasterRepository: Repository<EntityMaster>,
|
|
14
|
-
private readonly dataSource: DataSource,
|
|
15
14
|
@Inject('ListMasterService')
|
|
16
15
|
private readonly listMasterService: ListMasterService,
|
|
17
16
|
@InjectRepository(EntityRelation)
|
|
18
17
|
private readonly entityRelationRepo: Repository<EntityRelation>,
|
|
18
|
+
@InjectRepository(AttributeMaster)
|
|
19
|
+
private readonly attributeMasterRepository: Repository<AttributeMaster>
|
|
19
20
|
) {
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -92,20 +93,17 @@ export class EntityMasterRepository {
|
|
|
92
93
|
async getAttributesOfTypeDate(entity_type, loggedInUser) {
|
|
93
94
|
const organization_id = loggedInUser.organization_id;
|
|
94
95
|
|
|
95
|
-
const attributes = await this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
96
|
+
const attributes = await this.attributeMasterRepository.find({
|
|
97
|
+
where: {
|
|
98
|
+
mapped_entity_type: entity_type,
|
|
99
|
+
data_type: 'DATE',
|
|
100
|
+
organization_id
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
return attributes.map((attr) => ({
|
|
105
105
|
label: attr.name,
|
|
106
106
|
value: attr.attribute_key,
|
|
107
107
|
}));
|
|
108
|
-
|
|
109
|
-
return attributeList;
|
|
110
108
|
}
|
|
111
109
|
}
|
|
@@ -168,14 +168,6 @@ export class EntityDynamicService {
|
|
|
168
168
|
},
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
// const getRelation = await this.dataSource.query(
|
|
172
|
-
// `SELECT *
|
|
173
|
-
// FROM frm_entity_relation
|
|
174
|
-
// WHERE organization_id = $1
|
|
175
|
-
// AND source_entity_type = $2`,
|
|
176
|
-
// [organizationId, entityType],
|
|
177
|
-
// );
|
|
178
|
-
|
|
179
171
|
const { mappedEntities, ...mainData } = data;
|
|
180
172
|
|
|
181
173
|
// create main entity
|
|
@@ -220,23 +212,9 @@ export class EntityDynamicService {
|
|
|
220
212
|
source_entity_id: mainID,
|
|
221
213
|
source_entity_type: entityType,
|
|
222
214
|
target_entity_id: createdRelatedEntity.id,
|
|
223
|
-
|
|
215
|
+
target_entity_type: targetEntityType,
|
|
224
216
|
relation_type: relationType,
|
|
225
217
|
});
|
|
226
|
-
|
|
227
|
-
// await this.dataSource.query(
|
|
228
|
-
// `INSERT INTO frm_entity_relation_data (organization_id, source_entity_id, source_entity_type,
|
|
229
|
-
// target_entity_id, target_entity_type, relation_type)
|
|
230
|
-
// VALUES ($1, $2, $3, $4, $5, $6)`,
|
|
231
|
-
// [
|
|
232
|
-
// organizationId,
|
|
233
|
-
// mainID,
|
|
234
|
-
// entityType,
|
|
235
|
-
// createdRelatedEntity.id,
|
|
236
|
-
// targetEntityType,
|
|
237
|
-
// relationType,
|
|
238
|
-
// ],
|
|
239
|
-
// );
|
|
240
218
|
}
|
|
241
219
|
}
|
|
242
220
|
}
|
|
@@ -266,7 +244,10 @@ export class EntityDynamicService {
|
|
|
266
244
|
this.reflectionHelper.getRepoService('EntityRelationData');
|
|
267
245
|
|
|
268
246
|
const relations = await relationRepo.find({
|
|
269
|
-
where: {
|
|
247
|
+
where: {
|
|
248
|
+
source_entity_type: entityType,
|
|
249
|
+
organization_id: loggedInUser.organization_id,
|
|
250
|
+
},
|
|
270
251
|
});
|
|
271
252
|
|
|
272
253
|
const targetTypes = relations.map((r) => r.target_entity_type);
|
|
@@ -397,20 +378,6 @@ export class EntityDynamicService {
|
|
|
397
378
|
loggedInUser,
|
|
398
379
|
);
|
|
399
380
|
} else {
|
|
400
|
-
// Delete the related entity if we are creating a new one
|
|
401
|
-
// for (const existingRel of existingRelationsForType) {
|
|
402
|
-
// await this.deleteEntity(
|
|
403
|
-
// existingRel.target_entity_type,
|
|
404
|
-
// existingRel.target_entity_id,
|
|
405
|
-
// loggedInUser,
|
|
406
|
-
// );
|
|
407
|
-
|
|
408
|
-
// // Delete the relation row
|
|
409
|
-
// await this.dataSource.query(
|
|
410
|
-
// `DELETE FROM frm_entity_relation_data WHERE id = ?`,
|
|
411
|
-
// [existingRel.id],
|
|
412
|
-
// );
|
|
413
|
-
// }
|
|
414
381
|
// Create new entity
|
|
415
382
|
const createdEntity = await this.createEntity(
|
|
416
383
|
targetEntityType,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm';
|
|
2
1
|
import { Inject, Injectable } from '@nestjs/common';
|
|
3
2
|
import { UserData } from '../../user/entity/user.entity';
|
|
4
3
|
import * as moment from 'moment';
|
|
@@ -6,19 +5,23 @@ import { ListMasterService } from 'src/module/listmaster/service/list-master.ser
|
|
|
6
5
|
import { ModuleRef } from '@nestjs/core';
|
|
7
6
|
import { AttributeMasterRepository } from '../repository/attribute-master.repository';
|
|
8
7
|
import { ReflectionHelper } from 'src/utils/service/reflection-helper.service';
|
|
8
|
+
import { EntityMasterRepository } from '../repository/entity-master.repository';
|
|
9
|
+
import { EntityManager } from 'typeorm';
|
|
9
10
|
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class ResolverService {
|
|
12
13
|
private mediaDataService: any;
|
|
13
14
|
|
|
14
15
|
constructor(
|
|
15
|
-
private readonly dataSource: DataSource,
|
|
16
16
|
@Inject('ListMasterService')
|
|
17
17
|
private readonly listMasterService: ListMasterService,
|
|
18
18
|
private readonly moduleRef: ModuleRef,
|
|
19
19
|
private readonly attributeMasterRepo: AttributeMasterRepository,
|
|
20
20
|
private readonly reflectionHelper: ReflectionHelper,
|
|
21
|
-
|
|
21
|
+
private readonly entityMasterRepo: EntityMasterRepository,
|
|
22
|
+
private readonly entityManger: EntityManager,
|
|
23
|
+
) {
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
private async getMediaDataService() {
|
|
24
27
|
if (!this.mediaDataService) {
|
|
@@ -138,26 +141,12 @@ export class ResolverService {
|
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
// fetch attribute meta only for the given attributeKey
|
|
141
|
-
const
|
|
142
|
-
`SELECT *
|
|
143
|
-
FROM frm_entity_attribute
|
|
144
|
-
WHERE mapped_entity_type = $1
|
|
145
|
-
AND organization_id = $2
|
|
146
|
-
AND attribute_key = $3`,
|
|
147
|
-
[entityType, loggedInUser.organization_id, attrKey],
|
|
148
|
-
);
|
|
149
|
-
|
|
144
|
+
const attr = await this.attributeMasterRepo.findByMappedEntityTypeAndAttributeKeyAndOrganizationId(entityType, attrKey, loggedInUser.organization_id);
|
|
150
145
|
if (!attr) return rawValue;
|
|
151
146
|
|
|
152
147
|
// -------- ENTITY data_source_type --------
|
|
153
148
|
if (attr.data_source_type === 'entity') {
|
|
154
|
-
const
|
|
155
|
-
`SELECT *
|
|
156
|
-
FROM frm_entity_master
|
|
157
|
-
WHERE mapped_entity_type = $1
|
|
158
|
-
AND organization_id = $2`,
|
|
159
|
-
[attr.datasource_list, loggedInUser.organization_id],
|
|
160
|
-
);
|
|
149
|
+
const entityDef = await this.entityMasterRepo.getEntityByMappedEntityType(attr.datasource_list, loggedInUser.organization_id);
|
|
161
150
|
|
|
162
151
|
if (!entityDef) return rawValue;
|
|
163
152
|
|
|
@@ -181,7 +170,7 @@ export class ResolverService {
|
|
|
181
170
|
? [code]
|
|
182
171
|
: [code, loggedInUser.organization_id];
|
|
183
172
|
|
|
184
|
-
const [item] = await this.
|
|
173
|
+
const [item] = await this.entityManger.query(query, params);
|
|
185
174
|
resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
186
175
|
}
|
|
187
176
|
return resolvedValues;
|
|
@@ -201,7 +190,7 @@ export class ResolverService {
|
|
|
201
190
|
? [rawValue]
|
|
202
191
|
: [rawValue, loggedInUser.organization_id];
|
|
203
192
|
|
|
204
|
-
const [item] = await this.
|
|
193
|
+
const [item] = await this.entityManger.query(query, params);
|
|
205
194
|
return item?.[attr.data_source_attribute] ?? rawValue;
|
|
206
195
|
}
|
|
207
196
|
}
|
|
@@ -211,8 +200,7 @@ export class ResolverService {
|
|
|
211
200
|
if (Array.isArray(rawValue)) {
|
|
212
201
|
const resolvedValues: string[] = [];
|
|
213
202
|
for (const code of rawValue) {
|
|
214
|
-
const repo =
|
|
215
|
-
await this.reflectionHelper.getRepoService('ListMasterItems');
|
|
203
|
+
const repo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
216
204
|
|
|
217
205
|
let item = repo.findOne({
|
|
218
206
|
where: {
|
|
@@ -254,26 +242,13 @@ export class ResolverService {
|
|
|
254
242
|
}
|
|
255
243
|
|
|
256
244
|
// fetch attribute meta
|
|
257
|
-
const
|
|
258
|
-
`SELECT *
|
|
259
|
-
FROM frm_entity_attribute
|
|
260
|
-
WHERE mapped_entity_type = $1
|
|
261
|
-
AND organization_id = $2
|
|
262
|
-
AND attribute_key = $3`,
|
|
263
|
-
[entityType, loggedInUser.organization_id, attrKey],
|
|
264
|
-
);
|
|
245
|
+
const attr = await this.attributeMasterRepo.findByMappedEntityTypeAndAttributeKeyAndOrganizationId(entityType, attrKey, loggedInUser.organization_id);
|
|
265
246
|
|
|
266
247
|
if (!attr) return displayValue;
|
|
267
248
|
|
|
268
249
|
// -------- ENTITY data_source_type --------
|
|
269
250
|
if (attr.data_source_type === 'entity') {
|
|
270
|
-
const
|
|
271
|
-
`SELECT *
|
|
272
|
-
FROM frm_entity_master
|
|
273
|
-
WHERE mapped_entity_type = $1
|
|
274
|
-
AND organization_id = $2`,
|
|
275
|
-
[attr.datasource_list, loggedInUser.organization_id],
|
|
276
|
-
);
|
|
251
|
+
const entityDef =await this.entityMasterRepo.getEntityByMappedEntityType(attr.datasource_list, loggedInUser.organization_id);
|
|
277
252
|
|
|
278
253
|
if (!entityDef) return displayValue;
|
|
279
254
|
|
|
@@ -294,20 +269,21 @@ export class ResolverService {
|
|
|
294
269
|
? [displayValue]
|
|
295
270
|
: [displayValue, loggedInUser.organization_id];
|
|
296
271
|
|
|
297
|
-
const [item] = await this.
|
|
272
|
+
const [item] = await this.entityManger.query(query, params);
|
|
298
273
|
return item?.id ?? displayValue;
|
|
299
274
|
}
|
|
300
275
|
|
|
301
276
|
// -------- MASTER data_source_type --------
|
|
302
277
|
else if (attr.data_source_type === 'master') {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
)
|
|
278
|
+
const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
|
|
279
|
+
|
|
280
|
+
const item = await listMasterItemsRepo.findOne({
|
|
281
|
+
where: { [attr.data_source_attribute] : displayValue,
|
|
282
|
+
organization_id: loggedInUser.organization_id,
|
|
283
|
+
listtype: attr.datasource_list
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
|
|
311
287
|
return item?.id ?? displayValue;
|
|
312
288
|
}
|
|
313
289
|
|
|
@@ -102,7 +102,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
102
102
|
|
|
103
103
|
if (userId) {
|
|
104
104
|
// Check if user has any role mappings for the given appcode
|
|
105
|
-
const userRepo = this.reflectionHelper.getRepoService('
|
|
105
|
+
const userRepo = this.reflectionHelper.getRepoService('UserData');
|
|
106
106
|
const getUserDetails = await userRepo.findOne({
|
|
107
107
|
where: {
|
|
108
108
|
id: userId,
|