rez_core 2.1.75 → 2.1.77
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 +11 -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 +12 -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
|
@@ -41,6 +41,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
41
41
|
}
|
|
42
42
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
43
43
|
entityData.entity_type,
|
|
44
|
+
loggedInUser,
|
|
44
45
|
);
|
|
45
46
|
|
|
46
47
|
const validationErrors =
|
|
@@ -68,11 +69,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
68
69
|
);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
if (!entityData.code) {
|
|
72
|
+
if (!entityData.code && loggedInUser) {
|
|
72
73
|
let maxSeqNo = await this.getMaxSequenceNumber(
|
|
73
74
|
entityData.entity_type,
|
|
74
75
|
entityData.parent_id,
|
|
75
76
|
entityData.parent_type,
|
|
77
|
+
loggedInUser,
|
|
76
78
|
);
|
|
77
79
|
maxSeqNo = Number(maxSeqNo) + 1;
|
|
78
80
|
entityData.code = entityData.entity_type + maxSeqNo;
|
|
@@ -94,9 +96,11 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
94
96
|
return repo.save(entityData);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
async deleteEntity(entityType: string, entityId: number) {
|
|
98
|
-
const entityMaster =
|
|
99
|
-
|
|
99
|
+
async deleteEntity(entityType: string, entityId: number, loggedInUser) {
|
|
100
|
+
const entityMaster = await this.entityMasterService.getEntityData(
|
|
101
|
+
entityType,
|
|
102
|
+
loggedInUser,
|
|
103
|
+
);
|
|
100
104
|
|
|
101
105
|
const repoService = this.reflectionHelper.getRepoService(
|
|
102
106
|
entityMaster.entity_data_class,
|
|
@@ -121,8 +125,15 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
async findByCode(
|
|
125
|
-
|
|
128
|
+
async findByCode(
|
|
129
|
+
entityType: string,
|
|
130
|
+
code: string,
|
|
131
|
+
loggedInUser,
|
|
132
|
+
): Promise<BaseEntity> {
|
|
133
|
+
const entityData = await this.entityMasterService.getEntityData(
|
|
134
|
+
entityType,
|
|
135
|
+
loggedInUser,
|
|
136
|
+
);
|
|
126
137
|
|
|
127
138
|
const repoService = this.reflectionHelper.getRepoService(
|
|
128
139
|
entityData.entity_data_class,
|
|
@@ -143,8 +154,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
143
154
|
async getEntityData(
|
|
144
155
|
entityType: string,
|
|
145
156
|
id: number,
|
|
157
|
+
loggedInUser,
|
|
146
158
|
): Promise<BaseEntity | null> {
|
|
147
|
-
const entityData = await this.entityMasterService.getEntityData(
|
|
159
|
+
const entityData = await this.entityMasterService.getEntityData(
|
|
160
|
+
entityType,
|
|
161
|
+
loggedInUser,
|
|
162
|
+
);
|
|
148
163
|
|
|
149
164
|
const repoService = this.reflectionHelper.getRepoService(
|
|
150
165
|
entityData.entity_data_class,
|
|
@@ -160,8 +175,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
160
175
|
async getEntityDataAll(
|
|
161
176
|
entityType: string,
|
|
162
177
|
type: {},
|
|
178
|
+
loggedInUser: UserData,
|
|
163
179
|
): Promise<BaseEntity[] | null> {
|
|
164
|
-
const entityData = await this.entityMasterService.getEntityData(
|
|
180
|
+
const entityData = await this.entityMasterService.getEntityData(
|
|
181
|
+
entityType,
|
|
182
|
+
loggedInUser,
|
|
183
|
+
);
|
|
165
184
|
|
|
166
185
|
const repoService = this.reflectionHelper.getRepoService(
|
|
167
186
|
entityData.entity_data_class,
|
|
@@ -177,8 +196,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
177
196
|
async getEntityList(
|
|
178
197
|
entityType: string,
|
|
179
198
|
filters: Record<string, any> = {},
|
|
199
|
+
loggedInUser: UserData,
|
|
180
200
|
): Promise<BaseEntity[]> {
|
|
181
|
-
const entityData = await this.entityMasterService.getEntityData(
|
|
201
|
+
const entityData = await this.entityMasterService.getEntityData(
|
|
202
|
+
entityType,
|
|
203
|
+
loggedInUser,
|
|
204
|
+
);
|
|
182
205
|
const repoService = this.reflectionHelper.getRepoService(
|
|
183
206
|
entityData.entity_data_class,
|
|
184
207
|
);
|
|
@@ -203,6 +226,7 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
203
226
|
) {
|
|
204
227
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
205
228
|
entityData.entity_type,
|
|
229
|
+
loggedInUser,
|
|
206
230
|
);
|
|
207
231
|
|
|
208
232
|
const repoService = this.reflectionHelper.getRepoService(
|
|
@@ -342,13 +366,16 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
342
366
|
entityType: string,
|
|
343
367
|
parentId: number,
|
|
344
368
|
parentType: string,
|
|
369
|
+
loggedInUser: UserData,
|
|
345
370
|
): Promise<number> {
|
|
346
371
|
let tableName: string;
|
|
347
372
|
if (ENTITYTYPE_ENTITYMASTER === entityType) {
|
|
348
373
|
tableName = 'cr_entity_master';
|
|
349
374
|
} else {
|
|
350
|
-
let entityMaster =
|
|
351
|
-
|
|
375
|
+
let entityMaster = await this.entityMasterService.getEntityData(
|
|
376
|
+
entityType,
|
|
377
|
+
loggedInUser,
|
|
378
|
+
);
|
|
352
379
|
tableName = entityMaster.db_table_name;
|
|
353
380
|
}
|
|
354
381
|
return await this.entityListService.getMaxSequenceNumber(
|
|
@@ -6,6 +6,7 @@ import { DISPLAY_LIST } from '../../../constant/global.constant';
|
|
|
6
6
|
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
7
7
|
import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
|
|
8
8
|
import { SavedFilterRepositoryService } from 'src/module/filter/repository/saved-filter.repository';
|
|
9
|
+
import { UserData } from 'src/module/user/entity/user.entity';
|
|
9
10
|
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class EntityTableService {
|
|
@@ -20,11 +21,13 @@ export class EntityTableService {
|
|
|
20
21
|
private readonly savedFilterRepoService: SavedFilterRepositoryService,
|
|
21
22
|
) {}
|
|
22
23
|
|
|
23
|
-
async getEntityData(mappedEntityType: string | null) {
|
|
24
|
+
async getEntityData(mappedEntityType: string | null, loggedInUser) {
|
|
25
|
+
console.log(mappedEntityType,loggedInUser," loggedInUser in getEntityData");
|
|
24
26
|
if (mappedEntityType) {
|
|
25
27
|
const tableMaster =
|
|
26
28
|
await this.entityTableRepository.findByMappedEntityType(
|
|
27
29
|
mappedEntityType,
|
|
30
|
+
loggedInUser.organization_id,
|
|
28
31
|
);
|
|
29
32
|
|
|
30
33
|
if (!tableMaster) {
|
|
@@ -50,24 +53,26 @@ export class EntityTableService {
|
|
|
50
53
|
entityType: string,
|
|
51
54
|
listType: string,
|
|
52
55
|
displayType: string,
|
|
56
|
+
organization_id: number | null = null,
|
|
53
57
|
) {
|
|
54
58
|
return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(
|
|
55
59
|
entityType,
|
|
56
60
|
listType,
|
|
57
61
|
displayType,
|
|
62
|
+
organization_id ? organization_id : null,
|
|
58
63
|
);
|
|
59
64
|
}
|
|
60
65
|
|
|
61
66
|
async getTableMetaDataForListing(
|
|
62
67
|
entityType: string,
|
|
63
68
|
listType: string,
|
|
64
|
-
|
|
69
|
+
loggedInUser: any,
|
|
65
70
|
) {
|
|
66
71
|
return await this.getTableMetaData(
|
|
67
72
|
entityType,
|
|
68
73
|
listType,
|
|
69
74
|
DISPLAY_LIST,
|
|
70
|
-
|
|
75
|
+
loggedInUser,
|
|
71
76
|
);
|
|
72
77
|
}
|
|
73
78
|
|
|
@@ -75,12 +80,13 @@ export class EntityTableService {
|
|
|
75
80
|
entityType: string,
|
|
76
81
|
listType: string,
|
|
77
82
|
displayType: string,
|
|
78
|
-
|
|
83
|
+
loggedInUser: any,
|
|
79
84
|
) {
|
|
80
85
|
let entityTable = await this.findByEntityTypeAndListTypeAndDisplayType(
|
|
81
86
|
entityType,
|
|
82
87
|
listType,
|
|
83
88
|
displayType,
|
|
89
|
+
loggedInUser?.organization_id,
|
|
84
90
|
);
|
|
85
91
|
|
|
86
92
|
let entityTableDto = entityTable as EntityTableDto;
|
|
@@ -103,10 +109,10 @@ export class EntityTableService {
|
|
|
103
109
|
await this.savedFilterRepoService.getDefaultFilterByEntityType(
|
|
104
110
|
entityTable.list_type,
|
|
105
111
|
);
|
|
106
|
-
if (
|
|
112
|
+
if (loggedInUser.id) {
|
|
107
113
|
entityTableDto.saved_filter =
|
|
108
114
|
await this.savedFilterRepoService.getSavedFiltersByUserIdAndEntityType(
|
|
109
|
-
|
|
115
|
+
loggedInUser.id,
|
|
110
116
|
entityTable.list_type,
|
|
111
117
|
);
|
|
112
118
|
}
|
|
@@ -129,6 +129,7 @@ export class EntityValidationService {
|
|
|
129
129
|
const attributes =
|
|
130
130
|
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
131
131
|
entityData.entity_type,
|
|
132
|
+
loggedInUser.organization_id,
|
|
132
133
|
);
|
|
133
134
|
|
|
134
135
|
const requiredErrors = this.validateRequiredFields(entityData, attributes);
|
|
@@ -143,19 +144,19 @@ export class EntityValidationService {
|
|
|
143
144
|
return [...requiredErrors, ...uniqueErrors, ...regexErros];
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
async validateExcelEntityData(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
): Promise<ValidationError[]> {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
147
|
+
// async validateExcelEntityData(
|
|
148
|
+
// entityData: Record<string, any>,
|
|
149
|
+
// entityMaster,
|
|
150
|
+
// ): Promise<ValidationError[]> {
|
|
151
|
+
// const attributes =
|
|
152
|
+
// await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
153
|
+
// entityData.entity_type,
|
|
154
|
+
// );
|
|
155
|
+
|
|
156
|
+
// const requiredErrors = this.validateRequiredFields(entityData, attributes);
|
|
157
|
+
// const regexErros = await this.validateRegexFields(entityData, attributes);
|
|
158
|
+
// return [...requiredErrors, ...regexErros];
|
|
159
|
+
// }
|
|
159
160
|
private hasValidValue(value: any): boolean {
|
|
160
161
|
if (value === null || value === undefined) return false;
|
|
161
162
|
if (typeof value === 'string' && value.trim() === '') return false;
|
|
@@ -13,9 +13,14 @@ export interface EntityService<T extends BaseEntity> {
|
|
|
13
13
|
getEntityData(
|
|
14
14
|
entityType: string,
|
|
15
15
|
entityId: number,
|
|
16
|
+
loggedInUser: UserData,
|
|
16
17
|
): Promise<BaseEntity | null>;
|
|
17
18
|
|
|
18
|
-
getEntityList(
|
|
19
|
+
getEntityList(
|
|
20
|
+
entityType: string,
|
|
21
|
+
loggedInUser: UserData,
|
|
22
|
+
filters?: Record<string, any>,
|
|
23
|
+
): Promise<BaseEntity[]>;
|
|
19
24
|
|
|
20
25
|
updateEntity(
|
|
21
26
|
entityData: T,
|
|
@@ -29,7 +34,11 @@ export interface EntityService<T extends BaseEntity> {
|
|
|
29
34
|
loggedInUserData: UserData,
|
|
30
35
|
): void;
|
|
31
36
|
|
|
32
|
-
findByCode(
|
|
37
|
+
findByCode(
|
|
38
|
+
entityType: string,
|
|
39
|
+
code: string,
|
|
40
|
+
loggedInUser: UserData,
|
|
41
|
+
): Promise<BaseEntity>;
|
|
33
42
|
|
|
34
43
|
getFilterDataWithTabs(
|
|
35
44
|
entityType: string,
|
|
@@ -13,11 +13,12 @@ export class FieldGroupService extends EntityServiceImpl {
|
|
|
13
13
|
|
|
14
14
|
async createEntity(
|
|
15
15
|
entityData: BaseEntity,
|
|
16
|
-
loggedInUser: UserData
|
|
16
|
+
loggedInUser: UserData,
|
|
17
17
|
manager?: EntityManager,
|
|
18
18
|
): Promise<BaseEntity> {
|
|
19
19
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
20
20
|
entityData.entity_type,
|
|
21
|
+
loggedInUser,
|
|
21
22
|
);
|
|
22
23
|
entityData.parent_id = entityMaster.id;
|
|
23
24
|
entityData.parent_type = entityMaster.entity_type;
|
|
@@ -4,12 +4,14 @@ import { MediaDataRepository } from '../repository/media-data.repository';
|
|
|
4
4
|
import { ConfigService } from '@nestjs/config';
|
|
5
5
|
import { S3 } from 'aws-sdk';
|
|
6
6
|
import { MediaData } from '../entity/media-data.entity';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ENTITYTYPE_MEDIA,
|
|
9
|
+
STATUS_PENDING,
|
|
10
|
+
} from '../../../constant/global.constant';
|
|
8
11
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
12
|
|
|
10
13
|
@Injectable()
|
|
11
14
|
export class MediaDataService extends EntityServiceImpl {
|
|
12
|
-
|
|
13
15
|
constructor(
|
|
14
16
|
private readonly configService: ConfigService,
|
|
15
17
|
private readonly mediaRepository: MediaDataRepository,
|
|
@@ -32,6 +34,7 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
32
34
|
async generateMediaUploadDetails(
|
|
33
35
|
fileName: string,
|
|
34
36
|
mappedAttributeKey: string,
|
|
37
|
+
loggedInUser,
|
|
35
38
|
mappedEntityType?: string,
|
|
36
39
|
mappedEntityId?: number,
|
|
37
40
|
) {
|
|
@@ -62,7 +65,7 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
62
65
|
}
|
|
63
66
|
mediaData.media_url = s3Key;
|
|
64
67
|
|
|
65
|
-
let savedEntity = await super.createEntity(mediaData,
|
|
68
|
+
let savedEntity = await super.createEntity(mediaData, loggedInUser);
|
|
66
69
|
|
|
67
70
|
if (savedEntity) {
|
|
68
71
|
return { id: savedEntity.id, path: s3Key, uploadUrl };
|
|
@@ -115,16 +118,20 @@ export class MediaDataService extends EntityServiceImpl {
|
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
// New method to get the signed URL for the media (download link)
|
|
118
|
-
async getMediaDownloadUrl(id: number) {
|
|
121
|
+
async getMediaDownloadUrl(id: number, loggedInUser) {
|
|
119
122
|
try {
|
|
120
|
-
const entityData = await this.getEntityData(
|
|
123
|
+
const entityData = await this.getEntityData(
|
|
124
|
+
ENTITYTYPE_MEDIA,
|
|
125
|
+
id,
|
|
126
|
+
loggedInUser,
|
|
127
|
+
);
|
|
121
128
|
let mediaData = entityData as MediaData;
|
|
122
129
|
const signedUrl = await this.s3.getSignedUrlPromise('getObject', {
|
|
123
130
|
Bucket: this.bucketName,
|
|
124
131
|
Key: mediaData.media_url,
|
|
125
132
|
Expires: 60 * 5, // URL valid for 5 mins
|
|
126
133
|
});
|
|
127
|
-
return {signedUrl,fileName: mediaData.file_name,id:mediaData.id};
|
|
134
|
+
return { signedUrl, fileName: mediaData.file_name, id: mediaData.id };
|
|
128
135
|
} catch (error) {
|
|
129
136
|
console.error('Error generating signed URL for media:', error);
|
|
130
137
|
throw new Error('Failed to generate signed URL');
|
|
@@ -13,11 +13,12 @@ export class SectionMasterService extends EntityServiceImpl {
|
|
|
13
13
|
|
|
14
14
|
async createEntity(
|
|
15
15
|
entityData: BaseEntity,
|
|
16
|
-
loggedInUser: UserData
|
|
16
|
+
loggedInUser: UserData,
|
|
17
17
|
manager?: EntityManager,
|
|
18
18
|
): Promise<BaseEntity> {
|
|
19
19
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
20
20
|
entityData.entity_type,
|
|
21
|
+
loggedInUser,
|
|
21
22
|
);
|
|
22
23
|
entityData.parent_id = entityMaster.id;
|
|
23
24
|
entityData.parent_type = entityMaster.entity_type;
|
|
@@ -21,11 +21,12 @@ export class ViewMasterService extends EntityServiceImpl {
|
|
|
21
21
|
|
|
22
22
|
async createEntity(
|
|
23
23
|
entityData: ViewMaster,
|
|
24
|
-
loggedInUser: UserData
|
|
24
|
+
loggedInUser: UserData,
|
|
25
25
|
manager?: EntityManager,
|
|
26
26
|
): Promise<BaseEntity> {
|
|
27
27
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
28
28
|
entityData.entity_type,
|
|
29
|
+
loggedInUser,
|
|
29
30
|
);
|
|
30
31
|
entityData.parent_id = entityMaster.id;
|
|
31
32
|
entityData.parent_type = entityMaster.entity_type;
|
|
@@ -111,8 +111,9 @@ export class ModuleAccessController {
|
|
|
111
111
|
const appcode = userData?.appcode;
|
|
112
112
|
const level_type = userData?.level_type;
|
|
113
113
|
const level_id = userData?.level_id;
|
|
114
|
+
const organization_id = userData?.organization_id;
|
|
114
115
|
|
|
115
|
-
if (!userId || !appcode || !level_type || !level_id) {
|
|
116
|
+
if (!userId || !appcode || !level_type || !level_id || !organization_id) {
|
|
116
117
|
throw new BadRequestException('Invalid token data');
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -121,6 +122,7 @@ export class ModuleAccessController {
|
|
|
121
122
|
appcode,
|
|
122
123
|
level_type,
|
|
123
124
|
level_id,
|
|
125
|
+
organization_id,
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -14,6 +14,7 @@ import { UserRoleMapping } from '../user/entity/user-role-mapping.entity';
|
|
|
14
14
|
import { UserModule } from '../user/user.module';
|
|
15
15
|
import { Role } from '../user/entity/role.entity';
|
|
16
16
|
import { ModuleAccess } from './entity/module-access.entity';
|
|
17
|
+
import { ListMasterModule } from '../listmaster/listmaster.module';
|
|
17
18
|
|
|
18
19
|
@Module({
|
|
19
20
|
imports: [
|
|
@@ -27,6 +28,7 @@ import { ModuleAccess } from './entity/module-access.entity';
|
|
|
27
28
|
]),
|
|
28
29
|
UtilsModule,
|
|
29
30
|
UserModule,
|
|
31
|
+
ListMasterModule,
|
|
30
32
|
],
|
|
31
33
|
controllers: [MenuController, ModuleAccessController],
|
|
32
34
|
providers: [
|
|
@@ -2,11 +2,15 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
|
|
2
2
|
import { ModuleAccessRepository } from '../repository/module-access.repository';
|
|
3
3
|
import { RoleRepository } from 'src/module/user/repository/role.repository';
|
|
4
4
|
import { RoleService } from '../../user/service/role.service';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ENTITYTYPE_ROLE,
|
|
7
|
+
STATUS_INACTIVE,
|
|
8
|
+
} from '../../../constant/global.constant';
|
|
6
9
|
import { Role } from '../../user/entity/role.entity';
|
|
7
10
|
import { DataSource, EntityManager } from 'typeorm';
|
|
8
11
|
import { UserData } from 'src/module/user/entity/user.entity';
|
|
9
12
|
import { MenuRepository } from '../repository/menu.repository';
|
|
13
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
10
14
|
|
|
11
15
|
@Injectable()
|
|
12
16
|
export class ModuleAccessService {
|
|
@@ -14,6 +18,8 @@ export class ModuleAccessService {
|
|
|
14
18
|
private readonly moduleAccessRepository: ModuleAccessRepository,
|
|
15
19
|
private readonly menuRepository: MenuRepository,
|
|
16
20
|
private readonly dataSource: DataSource,
|
|
21
|
+
@Inject('ListMasterService')
|
|
22
|
+
private readonly listMasterService: ListMasterService,
|
|
17
23
|
) {}
|
|
18
24
|
|
|
19
25
|
async getModules({ appcode }: { appcode: string }) {
|
|
@@ -129,11 +135,13 @@ export class ModuleAccessService {
|
|
|
129
135
|
appcode,
|
|
130
136
|
level_type,
|
|
131
137
|
level_id,
|
|
138
|
+
organization_id,
|
|
132
139
|
}: {
|
|
133
140
|
userId: number;
|
|
134
141
|
appcode: string;
|
|
135
142
|
level_type: string;
|
|
136
143
|
level_id: number;
|
|
144
|
+
organization_id: number;
|
|
137
145
|
}) {
|
|
138
146
|
// Step 1: Resolve roles
|
|
139
147
|
const roleCodes = await this.menuRepository.resolveUserRoles(
|
|
@@ -165,7 +173,12 @@ export class ModuleAccessService {
|
|
|
165
173
|
|
|
166
174
|
const school = result?.[0];
|
|
167
175
|
|
|
168
|
-
|
|
176
|
+
const resolveStatus = await this.listMasterService.getResolvedListCode(
|
|
177
|
+
STATUS_INACTIVE,
|
|
178
|
+
organization_id || 0,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (!school || school.status === resolveStatus.id || 'INACTIVE') {
|
|
169
182
|
// Return only VIEW permissions
|
|
170
183
|
return allPermissions.filter((perm) => perm.action === 'VIEW');
|
|
171
184
|
}
|
|
@@ -9,6 +9,8 @@ import { UserService } from './user.service';
|
|
|
9
9
|
import { ConfigService } from '@nestjs/config';
|
|
10
10
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
11
11
|
import { DataSource, Repository } from 'typeorm';
|
|
12
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
13
|
+
import { STATUS_ACTIVE } from 'src/constant/global.constant';
|
|
12
14
|
|
|
13
15
|
@Injectable()
|
|
14
16
|
export class LoginService {
|
|
@@ -22,6 +24,8 @@ export class LoginService {
|
|
|
22
24
|
private readonly roleRepo: Repository<Role>,
|
|
23
25
|
private readonly dataSource: DataSource,
|
|
24
26
|
private readonly organizationRepository: OrganizationRepository,
|
|
27
|
+
@Inject('ListMasterService')
|
|
28
|
+
private readonly listMasterService: ListMasterService,
|
|
25
29
|
) {}
|
|
26
30
|
|
|
27
31
|
masterKey: string = this.configService.get('MASTER_KEY') || '';
|
|
@@ -41,7 +45,15 @@ export class LoginService {
|
|
|
41
45
|
user.organization_id,
|
|
42
46
|
);
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
const resolveStatus = await this.listMasterService.getResolvedListCode(
|
|
49
|
+
STATUS_ACTIVE,
|
|
50
|
+
user?.organization_id || 0,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (
|
|
54
|
+
user.status != resolveStatus.id ||
|
|
55
|
+
userOrgData?.status != resolveStatus.id
|
|
56
|
+
) {
|
|
45
57
|
return {
|
|
46
58
|
success: false,
|
|
47
59
|
message: 'Your account is inactive.',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
1
|
+
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
|
|
3
3
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
4
4
|
import { UserData } from '../entity/user.entity';
|
|
5
5
|
import { Role } from '../entity/role.entity';
|
|
6
|
-
import { ENTITYTYPE_ROLE } from 'src/constant/global.constant';
|
|
6
|
+
import { ENTITYTYPE_ROLE, STATUS_INACTIVE } from 'src/constant/global.constant';
|
|
7
7
|
import { RoleRepository } from '../repository/role.repository';
|
|
8
8
|
import { EntityManager, Repository } from 'typeorm';
|
|
9
9
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
10
10
|
import { ModuleAccess } from '../../module/entity/module-access.entity';
|
|
11
11
|
import { ServiceResult } from 'src/dtos/response';
|
|
12
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
12
13
|
|
|
13
14
|
@Injectable()
|
|
14
15
|
export class RoleService extends EntityServiceImpl {
|
|
@@ -17,6 +18,8 @@ export class RoleService extends EntityServiceImpl {
|
|
|
17
18
|
private readonly entityManager: EntityManager,
|
|
18
19
|
@InjectRepository(ModuleAccess)
|
|
19
20
|
private readonly moduleAccessRepo: Repository<ModuleAccess>,
|
|
21
|
+
@Inject('ListMasterService')
|
|
22
|
+
private readonly listMasterService: ListMasterService,
|
|
20
23
|
) {
|
|
21
24
|
super();
|
|
22
25
|
}
|
|
@@ -45,7 +48,11 @@ export class RoleService extends EntityServiceImpl {
|
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
const sourceRole = role.copy_from_role_id
|
|
48
|
-
? await this.getEntityData(
|
|
51
|
+
? await this.getEntityData(
|
|
52
|
+
ENTITYTYPE_ROLE,
|
|
53
|
+
role.copy_from_role_id,
|
|
54
|
+
loggedInUser,
|
|
55
|
+
)
|
|
49
56
|
: null;
|
|
50
57
|
|
|
51
58
|
if (role.copy_from_role_id && !sourceRole) {
|
|
@@ -83,11 +90,17 @@ export class RoleService extends EntityServiceImpl {
|
|
|
83
90
|
}
|
|
84
91
|
const role = entityData as Role;
|
|
85
92
|
|
|
86
|
-
|
|
93
|
+
const resolveStatus = await this.listMasterService.getResolvedListCode(
|
|
94
|
+
STATUS_INACTIVE,
|
|
95
|
+
loggedInUser?.organization_id || 0,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (entityData.status == resolveStatus.id || 'INACTIVE') {
|
|
87
99
|
//get role by id
|
|
88
100
|
const existingRole = await this.getEntityData(
|
|
89
101
|
ENTITYTYPE_ROLE,
|
|
90
102
|
entityData.id,
|
|
103
|
+
loggedInUser,
|
|
91
104
|
);
|
|
92
105
|
|
|
93
106
|
if (!existingRole) {
|
|
@@ -97,7 +110,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
97
110
|
const associatedUsers = await this.entityManager.query(`SELECT map.*
|
|
98
111
|
FROM cr_user_role_mapping map
|
|
99
112
|
JOIN cr_user usr ON map.user_id = usr.id
|
|
100
|
-
WHERE usr.status =
|
|
113
|
+
WHERE usr.status = ${resolveStatus.id}
|
|
101
114
|
and map.role_id = ${existingRole?.id}`);
|
|
102
115
|
|
|
103
116
|
if (associatedUsers.length > 0) {
|
|
@@ -134,6 +147,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
134
147
|
const sourceRole = await this.getEntityData(
|
|
135
148
|
ENTITYTYPE_ROLE,
|
|
136
149
|
role.copy_from_role_id,
|
|
150
|
+
loggedInUser,
|
|
137
151
|
);
|
|
138
152
|
|
|
139
153
|
if (!sourceRole) {
|
|
@@ -18,6 +18,7 @@ import { UpdateUserDto } from '../dto/update-user.dto';
|
|
|
18
18
|
import { ConfigService } from '@nestjs/config';
|
|
19
19
|
import { UserAppMappingService } from 'src/module/meta/service/user-app-mapping.service';
|
|
20
20
|
import { ServiceResult } from 'src/dtos/response.dto';
|
|
21
|
+
import { ListMasterService } from 'src/module/listmaster/service/list-master.service';
|
|
21
22
|
|
|
22
23
|
@Injectable()
|
|
23
24
|
export class UserService extends EntityServiceImpl {
|
|
@@ -28,6 +29,8 @@ export class UserService extends EntityServiceImpl {
|
|
|
28
29
|
private configService: ConfigService,
|
|
29
30
|
private readonly userAppMappingService: UserAppMappingService,
|
|
30
31
|
@Inject('RoleService') private readonly roleService: RoleService,
|
|
32
|
+
@Inject('ListMasterService')
|
|
33
|
+
private readonly listMasterService: ListMasterService,
|
|
31
34
|
) {
|
|
32
35
|
super();
|
|
33
36
|
}
|
|
@@ -58,6 +61,11 @@ export class UserService extends EntityServiceImpl {
|
|
|
58
61
|
return { success: false, error: 'User with this mobile already exists' };
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
const resolveStatus = await this.listMasterService.getResolvedListCode(
|
|
65
|
+
STATUS_ACTIVE,
|
|
66
|
+
loggedInUser?.organization_id || 0,
|
|
67
|
+
);
|
|
68
|
+
|
|
61
69
|
userData.name = (userData.first_name || '') + (userData.last_name || '');
|
|
62
70
|
userData.password = EncryptUtilService.encryptGCM(
|
|
63
71
|
userData.password || 'Admin@123',
|
|
@@ -67,7 +75,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
67
75
|
userData.is_firstlogin = 1;
|
|
68
76
|
userData.roles = [];
|
|
69
77
|
userData.invitation_status = 'SENT';
|
|
70
|
-
userData.status =
|
|
78
|
+
userData.status = resolveStatus.id || 'ACTIVE';
|
|
71
79
|
|
|
72
80
|
const savedData = await super.createEntity(userData, loggedInUser);
|
|
73
81
|
|
|
@@ -114,6 +122,7 @@ export class UserService extends EntityServiceImpl {
|
|
|
114
122
|
async getEntityData(
|
|
115
123
|
entityType: string,
|
|
116
124
|
id: number,
|
|
125
|
+
loggedInUser?: UserData,
|
|
117
126
|
): Promise<BaseEntity | null> {
|
|
118
127
|
const user = await this.userRepository.findById(id);
|
|
119
128
|
if (user) {
|
|
@@ -125,7 +134,11 @@ export class UserService extends EntityServiceImpl {
|
|
|
125
134
|
for (let i in userRoleMappings) {
|
|
126
135
|
const userRoleMapping = userRoleMappings[i];
|
|
127
136
|
const roleId = userRoleMapping.role_id;
|
|
128
|
-
const role = await super.getEntityData(
|
|
137
|
+
const role = await super.getEntityData(
|
|
138
|
+
ENTITYTYPE_ROLE,
|
|
139
|
+
roleId,
|
|
140
|
+
loggedInUser,
|
|
141
|
+
);
|
|
129
142
|
roles.push(role);
|
|
130
143
|
}
|
|
131
144
|
userDto.roles = roles;
|
|
@@ -21,6 +21,7 @@ import { UserRoleMappingService } from './service/user-role-mapping.service';
|
|
|
21
21
|
import { RoleRepository } from './repository/role.repository';
|
|
22
22
|
import { ModuleAccess } from '../module/entity/module-access.entity';
|
|
23
23
|
import { EnterpriseModule } from '../enterprise/enterprise.module';
|
|
24
|
+
import { ListMasterModule } from '../listmaster/listmaster.module';
|
|
24
25
|
|
|
25
26
|
@Module({
|
|
26
27
|
imports: [
|
|
@@ -34,6 +35,7 @@ import { EnterpriseModule } from '../enterprise/enterprise.module';
|
|
|
34
35
|
forwardRef(() => AuthModule),
|
|
35
36
|
EntityModule,
|
|
36
37
|
UtilsModule,
|
|
38
|
+
ListMasterModule,
|
|
37
39
|
forwardRef(() => EnterpriseModule),
|
|
38
40
|
],
|
|
39
41
|
providers: [
|