rez_core 7.0.8 → 7.0.10
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/controller/attribute-master.controller.d.ts +3 -0
- package/dist/module/meta/controller/attribute-master.controller.js +12 -0
- package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +7 -1
- package/dist/module/meta/service/attribute-master.service.js +52 -2
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/controller/attribute-master.controller.ts +9 -0
- package/src/module/meta/service/attribute-master.service.ts +60 -0
package/package.json
CHANGED
|
@@ -79,4 +79,13 @@ export class AttributeMasterController {
|
|
|
79
79
|
loggedInUser,
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
@Get('getAttributes')
|
|
84
|
+
async getAttributes(
|
|
85
|
+
@Param('entityType') entityType: string,
|
|
86
|
+
@Req() req: Request & { user: any },
|
|
87
|
+
) {
|
|
88
|
+
const loggedInUser = req.user.userData;
|
|
89
|
+
return await this.attributeMasterService.getEntityAttributes(entityType, loggedInUser);
|
|
90
|
+
}
|
|
82
91
|
}
|
|
@@ -6,6 +6,8 @@ import { EntityServiceImpl } from './entity-service-impl.service';
|
|
|
6
6
|
import { getDbColumnType, getDbDataTypeName } from '../../../constant/db-data-type.constant';
|
|
7
7
|
import { AttributeStorageType } from '../../../constant/attribute.constant';
|
|
8
8
|
import { StorageType } from '../../../constant/entity.constant';
|
|
9
|
+
import { EntityMasterService } from './entity-master.service';
|
|
10
|
+
import { EntityRelationService } from './entity-relation.service';
|
|
9
11
|
|
|
10
12
|
@Injectable()
|
|
11
13
|
export class AttributeMasterService {
|
|
@@ -13,6 +15,9 @@ export class AttributeMasterService {
|
|
|
13
15
|
private readonly attributeMasterRepository: AttributeMasterRepository,
|
|
14
16
|
@Inject(forwardRef(() => EntityServiceImpl))
|
|
15
17
|
private readonly entityServiceImpl: EntityServiceImpl,
|
|
18
|
+
@Inject('EntityMasterService')
|
|
19
|
+
private readonly entityMasterService: EntityMasterService,
|
|
20
|
+
private readonly entityRelationService: EntityRelationService,
|
|
16
21
|
) {
|
|
17
22
|
}
|
|
18
23
|
|
|
@@ -251,4 +256,59 @@ export class AttributeMasterService {
|
|
|
251
256
|
allowedElementTypes,
|
|
252
257
|
);
|
|
253
258
|
}
|
|
259
|
+
|
|
260
|
+
async getEntityAttributes(entityType: string, loggedInUser: UserData) {
|
|
261
|
+
let entityMaster = await this.entityMasterService.getEntityData(entityType, loggedInUser);
|
|
262
|
+
if (entityMaster.is_flat_json) {
|
|
263
|
+
return await this.getAttributeKeysForFlatJson(entityType, loggedInUser);
|
|
264
|
+
} else {
|
|
265
|
+
let attributeMasters = await this.attributeMasterRepository.findAttributesByMappedEntityType(entityType, loggedInUser);
|
|
266
|
+
return attributeMasters.map(attribute => ({
|
|
267
|
+
id: attribute.id,
|
|
268
|
+
name: attribute.name,
|
|
269
|
+
attribute_key: attribute.attribute_key,
|
|
270
|
+
element_type: attribute.element_type,
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async getAttributeKeysForFlatJson(entityType: string, loggedInUser: UserData) {
|
|
276
|
+
let attributes: any[] = [];
|
|
277
|
+
|
|
278
|
+
const mainAttributes = await this.attributeMasterRepository.findAttributesByMappedEntityType(entityType, loggedInUser);
|
|
279
|
+
|
|
280
|
+
mainAttributes.map(attribute => {
|
|
281
|
+
attributes.push({
|
|
282
|
+
id: attribute.id,
|
|
283
|
+
name: attribute.name,
|
|
284
|
+
attribute_key: `${entityType}__${attribute.attribute_key}`,
|
|
285
|
+
element_type: attribute.element_type,
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
const relatedRelations = await this.entityRelationService.getOneToOneRelations(
|
|
290
|
+
entityType,
|
|
291
|
+
loggedInUser.enterprise_id,
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const relatedEntityTypes = relatedRelations.map(
|
|
295
|
+
(r) => r.target_entity_type,
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
if (relatedEntityTypes.length > 0) {
|
|
299
|
+
for (const type of relatedEntityTypes) {
|
|
300
|
+
const attrs = await this.attributeMasterRepository.findAttributesByMappedEntityType(type, loggedInUser);
|
|
301
|
+
attrs.map(attribute => {
|
|
302
|
+
attributes.push({
|
|
303
|
+
id: attribute.id,
|
|
304
|
+
name: attribute.name,
|
|
305
|
+
attribute_key: `${type}__${attribute.attribute_key}`,
|
|
306
|
+
element_type: attribute.element_type,
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return attributes;
|
|
313
|
+
}
|
|
254
314
|
}
|