rez_core 2.1.75 → 2.1.76
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/constant/global.constant.d.ts +2 -2
- package/dist/constant/global.constant.js +2 -2
- package/dist/constant/global.constant.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +1 -5
- package/dist/module/filter/service/filter.service.js +4 -10
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +1 -1
- package/dist/module/filter/service/saved-filter.service.js +3 -3
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/layout_preference/controller/layout_preference.controller.js +2 -2
- package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
- package/dist/module/layout_preference/service/layout_preference.service.d.ts +2 -2
- package/dist/module/layout_preference/service/layout_preference.service.js +2 -2
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/listmaster/repository/list-master-items.repository.d.ts +2 -1
- package/dist/module/listmaster/repository/list-master-items.repository.js +14 -2
- package/dist/module/listmaster/repository/list-master-items.repository.js.map +1 -1
- package/dist/module/listmaster/repository/list-master.repository.d.ts +1 -1
- package/dist/module/listmaster/repository/list-master.repository.js +7 -2
- package/dist/module/listmaster/repository/list-master.repository.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +3 -2
- package/dist/module/listmaster/service/list-master.service.js +13 -5
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/master/controller/master.controller.d.ts +3 -1
- package/dist/module/master/controller/master.controller.js +5 -3
- package/dist/module/master/controller/master.controller.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +1 -1
- package/dist/module/master/service/master.service.js +5 -5
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.d.ts +3 -1
- package/dist/module/meta/controller/entity.controller.js +13 -11
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/controller/media.controller.d.ts +5 -1
- package/dist/module/meta/controller/media.controller.js +12 -8
- package/dist/module/meta/controller/media.controller.js.map +1 -1
- package/dist/module/meta/controller/meta.controller.js +2 -2
- package/dist/module/meta/controller/meta.controller.js.map +1 -1
- package/dist/module/meta/repository/attribute-master.repository.d.ts +1 -1
- package/dist/module/meta/repository/attribute-master.repository.js +2 -1
- package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
- package/dist/module/meta/repository/entity-table.repository.d.ts +2 -2
- package/dist/module/meta/repository/entity-table.repository.js +16 -6
- package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +1 -1
- package/dist/module/meta/service/attribute-master.service.js +2 -2
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +1 -1
- package/dist/module/meta/service/entity-master.service.js +5 -2
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +5 -5
- package/dist/module/meta/service/entity-service-impl.service.js +16 -16
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +4 -4
- package/dist/module/meta/service/entity-table.service.js +10 -10
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/entity-validation.service.d.ts +0 -1
- package/dist/module/meta/service/entity-validation.service.js +1 -7
- package/dist/module/meta/service/entity-validation.service.js.map +1 -1
- package/dist/module/meta/service/entity.service.d.ts +3 -3
- package/dist/module/meta/service/field-group.service.d.ts +1 -1
- package/dist/module/meta/service/field-group.service.js +1 -1
- package/dist/module/meta/service/field-group.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.d.ts +2 -2
- package/dist/module/meta/service/media-data.service.js +4 -4
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/meta/service/section-master.service.d.ts +1 -1
- package/dist/module/meta/service/section-master.service.js +1 -1
- package/dist/module/meta/service/section-master.service.js.map +1 -1
- package/dist/module/meta/service/view-master.service.d.ts +1 -1
- package/dist/module/meta/service/view-master.service.js +1 -1
- package/dist/module/meta/service/view-master.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.js +3 -1
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/module.module.js +2 -0
- package/dist/module/module/module.module.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +5 -2
- package/dist/module/module/service/module-access.service.js +13 -4
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +3 -1
- package/dist/module/user/service/login.service.js +10 -3
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +3 -1
- package/dist/module/user/service/role.service.js +12 -7
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +4 -2
- package/dist/module/user/service/user.service.js +10 -5
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +2 -0
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/constant/global.constant.ts +3 -4
- package/src/module/filter/service/filter.service.ts +5 -3
- package/src/module/filter/service/saved-filter.service.ts +6 -3
- package/src/module/layout_preference/controller/layout_preference.controller.ts +2 -1
- package/src/module/layout_preference/service/layout_preference.service.ts +3 -1
- package/src/module/listmaster/repository/list-master-items.repository.ts +18 -2
- package/src/module/listmaster/repository/list-master.repository.ts +7 -2
- package/src/module/listmaster/service/list-master.service.ts +39 -8
- package/src/module/master/controller/master.controller.ts +19 -11
- package/src/module/master/service/master.service.ts +5 -1
- package/src/module/meta/controller/entity.controller.ts +33 -12
- package/src/module/meta/controller/media.controller.ts +16 -5
- package/src/module/meta/controller/meta.controller.ts +2 -2
- package/src/module/meta/repository/attribute-master.repository.ts +5 -3
- package/src/module/meta/repository/entity-table.repository.ts +20 -5
- package/src/module/meta/service/attribute-master.service.ts +2 -1
- package/src/module/meta/service/entity-master.service.ts +9 -3
- package/src/module/meta/service/entity-service-impl.service.ts +38 -11
- package/src/module/meta/service/entity-table.service.ts +11 -6
- package/src/module/meta/service/entity-validation.service.ts +14 -13
- package/src/module/meta/service/entity.service.ts +11 -2
- package/src/module/meta/service/field-group.service.ts +2 -1
- package/src/module/meta/service/media-data.service.ts +13 -6
- package/src/module/meta/service/section-master.service.ts +2 -1
- package/src/module/meta/service/view-master.service.ts +2 -1
- package/src/module/module/controller/module-access.controller.ts +3 -1
- package/src/module/module/module.module.ts +2 -0
- package/src/module/module/service/module-access.service.ts +15 -2
- package/src/module/user/service/login.service.ts +13 -1
- package/src/module/user/service/role.service.ts +19 -5
- package/src/module/user/service/user.service.ts +15 -2
- package/src/module/user/user.module.ts +2 -0
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ export const ENTITYTYPE_USRROLMAP = 'URM';
|
|
|
15
15
|
export const ENTITYTYPE_SAVEDFILTERMASTER = 'SFM';
|
|
16
16
|
export const ENTITYTYPE_SAVEDFILTERDETAIL = 'SFD';
|
|
17
17
|
|
|
18
|
-
|
|
19
18
|
export const STORAGETYPE_SINGLEJSON = 'singlejson';
|
|
20
19
|
export const STORAGETYPE_COLUMN = 'column';
|
|
21
20
|
|
|
@@ -23,8 +22,8 @@ export const STORAGETYPE_COLUMN = 'column';
|
|
|
23
22
|
export const secretKey: string = process.env.secret_key || '';
|
|
24
23
|
|
|
25
24
|
// STATUS
|
|
26
|
-
export const STATUS_ACTIVE = '
|
|
27
|
-
export const STATUS_INACTIVE = '
|
|
25
|
+
export const STATUS_ACTIVE = 'STATUS_ACTIVE';
|
|
26
|
+
export const STATUS_INACTIVE = 'STATUS_INACTIVE';
|
|
28
27
|
export const STATUS_PENDING = 'PENDING';
|
|
29
28
|
|
|
30
29
|
// Entity Status
|
|
@@ -34,4 +33,4 @@ export const ENTITYSTATUS_PUBLISHED = 'published';
|
|
|
34
33
|
// Display Type
|
|
35
34
|
export const DISPLAY_LIST = 'LIST';
|
|
36
35
|
export const DISPLAY_EXPORT = 'EXPORT';
|
|
37
|
-
export const DISPLAY_REPORT = 'REPORT';
|
|
36
|
+
export const DISPLAY_REPORT = 'REPORT';
|
|
@@ -13,8 +13,6 @@ import * as moment from 'moment';
|
|
|
13
13
|
export class FilterService {
|
|
14
14
|
constructor(
|
|
15
15
|
private dataSource: DataSource,
|
|
16
|
-
private readonly entityMasterService: EntityMasterService,
|
|
17
|
-
private readonly attributeMasterService: AttributeMasterService,
|
|
18
16
|
private readonly entityTableService: EntityTableService,
|
|
19
17
|
private readonly entityTableColumnService: EntityTableColumnService,
|
|
20
18
|
@Inject('SavedFilterService')
|
|
@@ -91,7 +89,10 @@ export class FilterService {
|
|
|
91
89
|
} = loggedInUser || {};
|
|
92
90
|
|
|
93
91
|
// Fetch meta
|
|
94
|
-
const entityMeta = await this.entityTableService.getEntityData(
|
|
92
|
+
const entityMeta = await this.entityTableService.getEntityData(
|
|
93
|
+
entity_type,
|
|
94
|
+
loggedInUser,
|
|
95
|
+
);
|
|
95
96
|
const tableName = entityMeta?.data_source; // data_souce is the table name
|
|
96
97
|
if (!tableName)
|
|
97
98
|
throw new BadRequestException(`Invalid entity_type: ${entity_type}`);
|
|
@@ -101,6 +102,7 @@ export class FilterService {
|
|
|
101
102
|
entity_type,
|
|
102
103
|
entity_type,
|
|
103
104
|
'LIST',
|
|
105
|
+
organization_id,
|
|
104
106
|
);
|
|
105
107
|
|
|
106
108
|
if (!getTableMeta) {
|
|
@@ -78,6 +78,7 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
78
78
|
const existing = await this.getEntityData(
|
|
79
79
|
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
80
80
|
master.id,
|
|
81
|
+
loggedInUser,
|
|
81
82
|
);
|
|
82
83
|
|
|
83
84
|
if (!existing) {
|
|
@@ -119,9 +120,11 @@ export class SavedFilterService extends EntityServiceImpl {
|
|
|
119
120
|
return updated;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
async deleteEntity(entityType: string, entityId: number) {
|
|
123
|
-
const entityMaster =
|
|
124
|
-
|
|
123
|
+
async deleteEntity(entityType: string, entityId: number, loggedInUser) {
|
|
124
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
125
|
+
entityType,
|
|
126
|
+
loggedInUser,
|
|
127
|
+
);
|
|
125
128
|
|
|
126
129
|
const repoService = this.reflectionHelper.getRepoService(
|
|
127
130
|
entityMaster.entity_data_class,
|
|
@@ -31,12 +31,13 @@ export class LayoutPreferenceController {
|
|
|
31
31
|
@Query('sort_by') sort_by: string,
|
|
32
32
|
@Req() req: Request & { user: any },
|
|
33
33
|
) {
|
|
34
|
-
const
|
|
34
|
+
const userData = req.user.userData;
|
|
35
35
|
|
|
36
36
|
return this.layoutPreferenceService.getColumnValue(
|
|
37
37
|
entity_type,
|
|
38
38
|
column,
|
|
39
39
|
sort_by,
|
|
40
|
+
userData,
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
@@ -14,7 +14,7 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
14
14
|
super();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async createEntity(entityData: BaseEntity, loggedInUser: UserData
|
|
17
|
+
async createEntity(entityData: BaseEntity, loggedInUser: UserData) {
|
|
18
18
|
console.log('lap api called', entityData);
|
|
19
19
|
|
|
20
20
|
const { mapped_entity_type } = entityData as any;
|
|
@@ -54,12 +54,14 @@ export class LayoutPreferenceService extends EntityServiceImpl {
|
|
|
54
54
|
entity_type: string,
|
|
55
55
|
column: string,
|
|
56
56
|
sort_by: string,
|
|
57
|
+
loggedInUser: UserData,
|
|
57
58
|
): Promise<string[]> {
|
|
58
59
|
const getTableMeta =
|
|
59
60
|
await this.entityTableService.findByEntityTypeAndListTypeAndDisplayType(
|
|
60
61
|
entity_type,
|
|
61
62
|
entity_type,
|
|
62
63
|
'LIST',
|
|
64
|
+
loggedInUser?.organization_id,
|
|
63
65
|
);
|
|
64
66
|
|
|
65
67
|
const tableName = getTableMeta?.data_source;
|
|
@@ -20,14 +20,30 @@ export class ListMasterItemsRepository {
|
|
|
20
20
|
return this.repo.findOne({ where: { id } });
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async findItemsByType(type: string) {
|
|
23
|
+
async findItemsByType(type: string, organizationId?: number) {
|
|
24
24
|
const items = await this.repo.find({
|
|
25
|
-
where: {
|
|
25
|
+
where: {
|
|
26
|
+
listtype: type,
|
|
27
|
+
organization_id: organizationId,
|
|
28
|
+
status: 'ACTIVE',
|
|
29
|
+
},
|
|
26
30
|
order: { sortindex: 'ASC' },
|
|
27
31
|
});
|
|
28
32
|
return items.map((i) => ({ label: i.name, value: i.id }));
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
async findItemByCode(
|
|
36
|
+
code: string,
|
|
37
|
+
organizationId?: number,
|
|
38
|
+
): Promise<ListMasterItems | null> {
|
|
39
|
+
return this.repo.findOne({
|
|
40
|
+
where: {
|
|
41
|
+
code: code,
|
|
42
|
+
organization_id: organizationId,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
async findAllItemsByListType(
|
|
32
48
|
type: string,
|
|
33
49
|
sortBy: string,
|
|
@@ -10,8 +10,13 @@ export class ListMasterRepository {
|
|
|
10
10
|
private readonly repo: Repository<ListMasterData>,
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
|
-
findByType(type: string) {
|
|
14
|
-
return this.repo.findOne({
|
|
13
|
+
findByType(type: string, organizationId?: number) {
|
|
14
|
+
return this.repo.findOne({
|
|
15
|
+
where: {
|
|
16
|
+
type: type,
|
|
17
|
+
organization_id: organizationId,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
// much better generic find method
|
|
@@ -30,13 +30,32 @@ export class ListMasterService {
|
|
|
30
30
|
|
|
31
31
|
private readonly skipLevelFilterEntities = ['BRN'];
|
|
32
32
|
|
|
33
|
+
async getResolvedListCode(
|
|
34
|
+
code: string,
|
|
35
|
+
organization_id: number,
|
|
36
|
+
): Promise<any> {
|
|
37
|
+
if (!code) return code;
|
|
38
|
+
|
|
39
|
+
// Check if it's a valid list type
|
|
40
|
+
const listMaster = await this.listItemsRepo.findItemByCode(
|
|
41
|
+
code,
|
|
42
|
+
organization_id,
|
|
43
|
+
);
|
|
44
|
+
if (listMaster) {
|
|
45
|
+
return listMaster;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
async getDropdownOptions(
|
|
34
50
|
type: string,
|
|
35
51
|
params: Record<string, string>,
|
|
36
52
|
inactiveIdsArray?: number[],
|
|
37
|
-
loggedInUser
|
|
53
|
+
loggedInUser?,
|
|
38
54
|
) {
|
|
39
|
-
const config = await this.listMasterRepo.findByType(
|
|
55
|
+
const config = await this.listMasterRepo.findByType(
|
|
56
|
+
type,
|
|
57
|
+
loggedInUser?.organization_id,
|
|
58
|
+
);
|
|
40
59
|
|
|
41
60
|
if (!config) throw new NotFoundException(`Type ${type} not found`);
|
|
42
61
|
|
|
@@ -50,7 +69,10 @@ export class ListMasterService {
|
|
|
50
69
|
);
|
|
51
70
|
|
|
52
71
|
case 'master':
|
|
53
|
-
return this.listItemsRepo.findItemsByType(
|
|
72
|
+
return this.listItemsRepo.findItemsByType(
|
|
73
|
+
type,
|
|
74
|
+
loggedInUser?.organization_id,
|
|
75
|
+
);
|
|
54
76
|
|
|
55
77
|
case 'custom':
|
|
56
78
|
return this.fetchFromExternalSource(config.custom_source_id, params);
|
|
@@ -60,7 +82,6 @@ export class ListMasterService {
|
|
|
60
82
|
}
|
|
61
83
|
}
|
|
62
84
|
|
|
63
|
-
|
|
64
85
|
private async fetchFromEntity(
|
|
65
86
|
sourceList: string,
|
|
66
87
|
params: Record<string, any>,
|
|
@@ -70,8 +91,10 @@ export class ListMasterService {
|
|
|
70
91
|
let result: { label: string; value: number }[] = [];
|
|
71
92
|
if (!sourceList) return result;
|
|
72
93
|
|
|
73
|
-
const entityMaster =
|
|
74
|
-
|
|
94
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
95
|
+
sourceList,
|
|
96
|
+
loggedInUser,
|
|
97
|
+
);
|
|
75
98
|
const tableName = entityMaster.db_table_name;
|
|
76
99
|
|
|
77
100
|
const applyCommonFilters = (
|
|
@@ -297,8 +320,16 @@ export class ListMasterService {
|
|
|
297
320
|
return await this.entityServiceImpl.updateEntity(entityData, loggedInUser);
|
|
298
321
|
}
|
|
299
322
|
|
|
300
|
-
async getEntityData(
|
|
301
|
-
|
|
323
|
+
async getEntityData(
|
|
324
|
+
entity_type: string,
|
|
325
|
+
id: number,
|
|
326
|
+
loggedInUser,
|
|
327
|
+
): Promise<any> {
|
|
328
|
+
return await this.entityServiceImpl.getEntityData(
|
|
329
|
+
entity_type,
|
|
330
|
+
id,
|
|
331
|
+
loggedInUser,
|
|
332
|
+
);
|
|
302
333
|
}
|
|
303
334
|
|
|
304
335
|
async getAllListMasterByOrganization(
|
|
@@ -21,13 +21,13 @@ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
|
21
21
|
@Controller('master')
|
|
22
22
|
@UseGuards(JwtAuthGuard)
|
|
23
23
|
export class MasterController {
|
|
24
|
-
constructor(
|
|
25
|
-
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly masterService: MasterService,
|
|
26
|
+
private readonly entityService: EntityServiceImpl,
|
|
26
27
|
) {}
|
|
27
28
|
|
|
28
29
|
@Post('uploadMeta')
|
|
29
30
|
@UseInterceptors(FileInterceptor('file'))
|
|
30
|
-
|
|
31
31
|
async uploadMasterMetaXls(@UploadedFile() file: Express.Multer.File) {
|
|
32
32
|
if (!file) {
|
|
33
33
|
throw new BadRequestException('File is required');
|
|
@@ -37,12 +37,15 @@ export class MasterController {
|
|
|
37
37
|
|
|
38
38
|
@Post('uploadData')
|
|
39
39
|
@UseInterceptors(FileInterceptor('file'))
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
async uploadMasterDataXls(
|
|
41
|
+
@UploadedFile() file: Express.Multer.File,
|
|
42
|
+
@Req() req: Request & { user: any },
|
|
43
|
+
) {
|
|
44
|
+
let loggedInUser = req.user.userData;
|
|
42
45
|
if (!file) {
|
|
43
46
|
throw new BadRequestException('File is required');
|
|
44
47
|
}
|
|
45
|
-
return await this.masterService.uploadData(file.buffer);
|
|
48
|
+
return await this.masterService.uploadData(file.buffer, loggedInUser);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
@Post('uploadEntity/:entityType')
|
|
@@ -51,16 +54,21 @@ export class MasterController {
|
|
|
51
54
|
@Param('entityType') entityType: string,
|
|
52
55
|
@UploadedFile() file: Express.Multer.File,
|
|
53
56
|
@Req() req: Request & { user: any },
|
|
54
|
-
@Body('duplicateHandling')
|
|
57
|
+
@Body('duplicateHandling')
|
|
58
|
+
duplicateHandling: 'skip_duplicates' | 'overwrite_items',
|
|
55
59
|
) {
|
|
56
60
|
let loggedInUser = req.user.userData;
|
|
57
61
|
// let loggedInUser = await this.entityService.getEntityData(ENTITYTYPE_USER, requestedUser.userId);
|
|
58
|
-
|
|
62
|
+
|
|
59
63
|
if (!file) {
|
|
60
64
|
throw new BadRequestException('File is required');
|
|
61
65
|
}
|
|
62
|
-
|
|
63
|
-
return await this.masterService.uploadEntityData(
|
|
66
|
+
|
|
67
|
+
return await this.masterService.uploadEntityData(
|
|
68
|
+
file.buffer,
|
|
69
|
+
entityType,
|
|
70
|
+
loggedInUser,
|
|
71
|
+
duplicateHandling,
|
|
72
|
+
);
|
|
64
73
|
}
|
|
65
|
-
|
|
66
74
|
}
|
|
@@ -146,7 +146,7 @@ export class MasterService {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
async uploadData(file) {
|
|
149
|
+
async uploadData(file, loggedInUser) {
|
|
150
150
|
const data = ExcelUtil.readExcel(file.buffer);
|
|
151
151
|
|
|
152
152
|
for (let i = 0; i < this.dataSequence.length; i++) {
|
|
@@ -164,6 +164,7 @@ export class MasterService {
|
|
|
164
164
|
const attributes =
|
|
165
165
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
166
166
|
entityMasterData?.mapped_entity_type,
|
|
167
|
+
loggedInUser.organization_id,
|
|
167
168
|
);
|
|
168
169
|
|
|
169
170
|
for (const row of sheetData) {
|
|
@@ -175,6 +176,7 @@ export class MasterService {
|
|
|
175
176
|
if (attribute.data_source_type === 'entity') {
|
|
176
177
|
let entityMaster = await this.entityMasterService.getEntityData(
|
|
177
178
|
attribute.datasource_list,
|
|
179
|
+
loggedInUser,
|
|
178
180
|
);
|
|
179
181
|
const entityData = await this.entityManager.query(
|
|
180
182
|
`SELECT * FROM ${entityMaster.db_table_name} WHERE code = ? LIMIT 1`,
|
|
@@ -215,6 +217,7 @@ export class MasterService {
|
|
|
215
217
|
const attributes =
|
|
216
218
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
217
219
|
entityType,
|
|
220
|
+
loggedInUser.organization_id,
|
|
218
221
|
);
|
|
219
222
|
const uniqueFields = attributes
|
|
220
223
|
.filter((attr) => attr.is_unique)
|
|
@@ -233,6 +236,7 @@ export class MasterService {
|
|
|
233
236
|
if (attr.data_source_type === 'entity' && row[attr.attribute_key]) {
|
|
234
237
|
const refEntity = await this.entityMasterService.getEntityData(
|
|
235
238
|
attr.datasource_list,
|
|
239
|
+
loggedInUser,
|
|
236
240
|
);
|
|
237
241
|
const refData = await this.entityManager.query(
|
|
238
242
|
`SELECT * FROM ${refEntity.db_table_name} WHERE code = ? LIMIT 1`,
|
|
@@ -41,15 +41,20 @@ export class EntityController {
|
|
|
41
41
|
// @Roles('USR', 'VIEW')
|
|
42
42
|
async getById(
|
|
43
43
|
@Param('id') id: number,
|
|
44
|
+
@Req() req: Request & { user: any },
|
|
44
45
|
@Query('entity_type') entityType?: string,
|
|
45
46
|
) {
|
|
47
|
+
const loggedInUser = req.user.userData;
|
|
48
|
+
|
|
46
49
|
if (!entityType) {
|
|
47
50
|
throw new BadRequestException(
|
|
48
51
|
'Query parameter "entity_type" is required',
|
|
49
52
|
);
|
|
50
53
|
}
|
|
51
|
-
const entityMaster =
|
|
52
|
-
|
|
54
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
55
|
+
entityType,
|
|
56
|
+
loggedInUser,
|
|
57
|
+
);
|
|
53
58
|
|
|
54
59
|
const entityService =
|
|
55
60
|
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
@@ -57,7 +62,7 @@ export class EntityController {
|
|
|
57
62
|
);
|
|
58
63
|
|
|
59
64
|
if (entityService) {
|
|
60
|
-
return await entityService.getEntityData(entityType, id);
|
|
65
|
+
return await entityService.getEntityData(entityType, id, loggedInUser);
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -77,8 +82,10 @@ export class EntityController {
|
|
|
77
82
|
);
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
const entityMaster =
|
|
81
|
-
|
|
85
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
86
|
+
entityType,
|
|
87
|
+
loggedInUser,
|
|
88
|
+
);
|
|
82
89
|
const entityService =
|
|
83
90
|
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
84
91
|
entityMaster.entity_service,
|
|
@@ -114,8 +121,10 @@ export class EntityController {
|
|
|
114
121
|
);
|
|
115
122
|
}
|
|
116
123
|
|
|
117
|
-
const entityMaster =
|
|
118
|
-
|
|
124
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
125
|
+
entityType,
|
|
126
|
+
loggedInUser,
|
|
127
|
+
);
|
|
119
128
|
|
|
120
129
|
const entityService =
|
|
121
130
|
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
@@ -128,7 +137,12 @@ export class EntityController {
|
|
|
128
137
|
);
|
|
129
138
|
}
|
|
130
139
|
|
|
131
|
-
const existingEntity = await entityService.getEntityData(
|
|
140
|
+
const existingEntity = await entityService.getEntityData(
|
|
141
|
+
entityType,
|
|
142
|
+
id,
|
|
143
|
+
loggedInUser,
|
|
144
|
+
);
|
|
145
|
+
|
|
132
146
|
if (!existingEntity) {
|
|
133
147
|
throw new NotFoundException(`No entity found for id "${id}"`);
|
|
134
148
|
}
|
|
@@ -159,8 +173,10 @@ export class EntityController {
|
|
|
159
173
|
);
|
|
160
174
|
}
|
|
161
175
|
|
|
162
|
-
const entityMaster =
|
|
163
|
-
|
|
176
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
177
|
+
entityType,
|
|
178
|
+
loggedInUser,
|
|
179
|
+
);
|
|
164
180
|
|
|
165
181
|
const entityService =
|
|
166
182
|
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
@@ -173,12 +189,17 @@ export class EntityController {
|
|
|
173
189
|
);
|
|
174
190
|
}
|
|
175
191
|
|
|
176
|
-
const existingEntity = await entityService.getEntityData(
|
|
192
|
+
const existingEntity = await entityService.getEntityData(
|
|
193
|
+
entityType,
|
|
194
|
+
id,
|
|
195
|
+
loggedInUser,
|
|
196
|
+
);
|
|
197
|
+
|
|
177
198
|
if (!existingEntity) {
|
|
178
199
|
throw new NotFoundException(`No entity found for id "${id}"`);
|
|
179
200
|
}
|
|
180
201
|
|
|
181
|
-
return await entityService.deleteEntity(entityType, id);
|
|
202
|
+
return await entityService.deleteEntity(entityType, id, loggedInUser);
|
|
182
203
|
}
|
|
183
204
|
|
|
184
205
|
@Post('getFilteredDataWithTabs/:entity_type')
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Get,
|
|
8
8
|
Param,
|
|
9
9
|
UseGuards,
|
|
10
|
+
Req,
|
|
10
11
|
} from '@nestjs/common';
|
|
11
12
|
import { MediaDataService } from '../service/media-data.service';
|
|
12
13
|
import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
|
|
@@ -29,11 +30,15 @@ export class MediaController {
|
|
|
29
30
|
mapped_entity_type?: string;
|
|
30
31
|
mapped_entity_id?: number;
|
|
31
32
|
},
|
|
33
|
+
@Req() req: Request & { user: any },
|
|
32
34
|
@Res() res: Response,
|
|
33
35
|
) {
|
|
36
|
+
const loggedInUser = req.user.userData;
|
|
37
|
+
|
|
34
38
|
let result = await this.mediaDataService.generateMediaUploadDetails(
|
|
35
39
|
body.file_name,
|
|
36
40
|
body.attribute_key,
|
|
41
|
+
loggedInUser,
|
|
37
42
|
body.mapped_entity_type,
|
|
38
43
|
body.mapped_entity_id,
|
|
39
44
|
);
|
|
@@ -50,15 +55,21 @@ export class MediaController {
|
|
|
50
55
|
|
|
51
56
|
// Method to fetch the download URL for a media file
|
|
52
57
|
@Get('download/:id')
|
|
53
|
-
async getDownloadUrl(
|
|
58
|
+
async getDownloadUrl(
|
|
59
|
+
@Param('id') id: number,
|
|
60
|
+
@Res() res: Response,
|
|
61
|
+
@Req() req: Request & { user: any },
|
|
62
|
+
) {
|
|
63
|
+
const loggedInUser = req.user.userData;
|
|
54
64
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
const downloadUrl = await this.mediaDataService.getMediaDownloadUrl(
|
|
66
|
+
id,
|
|
67
|
+
loggedInUser,
|
|
68
|
+
);
|
|
58
69
|
res.status(HttpStatus.OK).json({
|
|
59
70
|
message: 'Download URL fetched successfully',
|
|
60
71
|
success: true,
|
|
61
|
-
data:
|
|
72
|
+
data: downloadUrl,
|
|
62
73
|
});
|
|
63
74
|
} catch (error) {
|
|
64
75
|
res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
@@ -23,12 +23,12 @@ export class MetaController {
|
|
|
23
23
|
@Res() response: Response,
|
|
24
24
|
@Req() req: Request & { user: any },
|
|
25
25
|
) {
|
|
26
|
-
const
|
|
26
|
+
const loggedInUser = req.user.userData;
|
|
27
27
|
let entityTableDto =
|
|
28
28
|
await this.entityTableService.getTableMetaDataForListing(
|
|
29
29
|
entityType,
|
|
30
30
|
listType,
|
|
31
|
-
|
|
31
|
+
loggedInUser,
|
|
32
32
|
);
|
|
33
33
|
return response.status(HttpStatus.OK).json({
|
|
34
34
|
success: true,
|
|
@@ -26,13 +26,15 @@ export class AttributeMasterRepository {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
async findAttributesByMappedEntityType(
|
|
30
|
+
entityType: string,
|
|
31
|
+
organizationId: number,
|
|
32
|
+
): Promise<AttributeMaster[]> {
|
|
31
33
|
return await this.attributeMasterRepository.find({
|
|
32
34
|
where: {
|
|
33
35
|
mapped_entity_type: In([entityType, 'DEF']),
|
|
36
|
+
organization_id: organizationId,
|
|
34
37
|
},
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
|
-
|
|
38
40
|
}
|
|
@@ -17,9 +17,16 @@ export class EntityTableRepository {
|
|
|
17
17
|
return temp;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async findByMappedEntityType(
|
|
20
|
+
async findByMappedEntityType(
|
|
21
|
+
mappedEntityType: string,
|
|
22
|
+
organization_id: number,
|
|
23
|
+
) {
|
|
21
24
|
return await this.entityTableRepository.findOne({
|
|
22
|
-
where: {
|
|
25
|
+
where: {
|
|
26
|
+
mapped_entity_type: mappedEntityType,
|
|
27
|
+
display_type: 'LIST',
|
|
28
|
+
organization_id: organization_id,
|
|
29
|
+
},
|
|
23
30
|
});
|
|
24
31
|
}
|
|
25
32
|
|
|
@@ -27,12 +34,20 @@ export class EntityTableRepository {
|
|
|
27
34
|
entityType: string,
|
|
28
35
|
listType: string,
|
|
29
36
|
displayType: string,
|
|
37
|
+
organization_id: number | null = null,
|
|
30
38
|
) {
|
|
39
|
+
const whereCondition: any = {
|
|
40
|
+
mapped_entity_type: entityType,
|
|
41
|
+
list_type: listType,
|
|
42
|
+
display_type: displayType,
|
|
43
|
+
};
|
|
44
|
+
if (organization_id !== null) {
|
|
45
|
+
whereCondition.organization_id = organization_id;
|
|
46
|
+
}
|
|
47
|
+
|
|
31
48
|
return await this.entityTableRepository.findOne({
|
|
32
49
|
where: {
|
|
33
|
-
|
|
34
|
-
list_type: listType,
|
|
35
|
-
display_type: displayType,
|
|
50
|
+
...whereCondition,
|
|
36
51
|
},
|
|
37
52
|
});
|
|
38
53
|
}
|
|
@@ -9,9 +9,10 @@ export class AttributeMasterService {
|
|
|
9
9
|
private readonly attributeMasterRepository: AttributeMasterRepository,
|
|
10
10
|
) {}
|
|
11
11
|
|
|
12
|
-
async findAttributesByMappedEntityType(entity_type) {
|
|
12
|
+
async findAttributesByMappedEntityType(entity_type, organization_id) {
|
|
13
13
|
return await this.attributeMasterRepository.findAttributesByMappedEntityType(
|
|
14
14
|
entity_type,
|
|
15
|
+
organization_id,
|
|
15
16
|
);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -10,10 +10,16 @@ export class EntityMasterService {
|
|
|
10
10
|
private entityMasterRepository: Repository<EntityMaster>,
|
|
11
11
|
) {}
|
|
12
12
|
|
|
13
|
-
async getEntityData(
|
|
13
|
+
async getEntityData(
|
|
14
|
+
mappedEntityType: string | null,
|
|
15
|
+
loggedInUser,
|
|
16
|
+
): Promise<EntityMaster> {
|
|
14
17
|
if (mappedEntityType) {
|
|
15
18
|
const entityMaster = await this.entityMasterRepository.findOne({
|
|
16
|
-
where: {
|
|
19
|
+
where: {
|
|
20
|
+
mapped_entity_type: mappedEntityType,
|
|
21
|
+
organization_id: loggedInUser.organization_id,
|
|
22
|
+
},
|
|
17
23
|
});
|
|
18
24
|
|
|
19
25
|
if (!entityMaster) {
|
|
@@ -29,7 +35,7 @@ export class EntityMasterService {
|
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
async getEntityByTableName(tableName: string) {
|
|
32
|
-
const entityMaster = await this.entityMasterRepository.findOne({
|
|
38
|
+
const entityMaster = await this.entityMasterRepository.findOne({
|
|
33
39
|
where: { db_table_name: tableName },
|
|
34
40
|
});
|
|
35
41
|
return entityMaster;
|