rez_core 2.0.1 → 2.0.2
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/entity.controller.d.ts +1 -1
- package/dist/module/meta/controller/entity.controller.js +14 -11
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/meta/service/entity-list.service.d.ts +2 -2
- package/dist/module/meta/service/entity-list.service.js +18 -7
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +3 -3
- package/dist/module/meta/service/entity-service-impl.service.js +4 -4
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity.service.d.ts +2 -2
- package/dist/module/module/controller/module-access.controller.d.ts +5 -5
- package/dist/module/module/controller/module-access.controller.js +28 -16
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +10 -6
- package/dist/module/module/repository/module-access.repository.js +45 -29
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +9 -5
- package/dist/module/module/service/module-access.service.js +12 -10
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/user/dto/create-user.dto.d.ts +1 -0
- package/dist/module/user/dto/create-user.dto.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +1 -1
- package/dist/module/user/service/role.service.js +4 -1
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +1 -1
- package/dist/module/user/service/user.service.js +4 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/controller/entity.controller.ts +27 -12
- package/src/module/meta/service/entity-list.service.ts +29 -7
- package/src/module/meta/service/entity-service-impl.service.ts +29 -17
- package/src/module/meta/service/entity.service.ts +2 -1
- package/src/module/module/controller/module-access.controller.ts +48 -21
- package/src/module/module/repository/module-access.repository.ts +69 -50
- package/src/module/module/service/module-access.service.ts +15 -13
- package/src/module/user/dto/create-user.dto.ts +1 -0
- package/src/module/user/service/role.service.ts +5 -1
- package/src/module/user/service/user.service.ts +4 -0
package/package.json
CHANGED
|
@@ -2,14 +2,17 @@ import {
|
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Body,
|
|
4
4
|
Controller,
|
|
5
|
-
Get,
|
|
5
|
+
Get,
|
|
6
|
+
HttpCode,
|
|
6
7
|
HttpStatus,
|
|
7
8
|
Param,
|
|
8
9
|
Post,
|
|
9
10
|
Query,
|
|
10
11
|
Res,
|
|
11
12
|
Req,
|
|
12
|
-
UseGuards,
|
|
13
|
+
UseGuards,
|
|
14
|
+
Inject,
|
|
15
|
+
Request,
|
|
13
16
|
} from '@nestjs/common';
|
|
14
17
|
import { EntityServiceImpl } from '../service/entity-service-impl.service';
|
|
15
18
|
import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
|
|
@@ -62,11 +65,11 @@ export class EntityController {
|
|
|
62
65
|
@Body() entityData: BaseEntity,
|
|
63
66
|
@Query('entity_type') entityType: string,
|
|
64
67
|
@Res() res: Response,
|
|
65
|
-
@Req() req: Request & {user: any}
|
|
68
|
+
@Req() req: Request & { user: any },
|
|
66
69
|
) {
|
|
67
70
|
let requestedUser = req.user;
|
|
71
|
+
let appcode = requestedUser.appcode;
|
|
68
72
|
let loggedInUser = await this.entityService.getEntityData(ENTITYTYPE_USER,requestedUser.userId);
|
|
69
|
-
|
|
70
73
|
if (!entityType) {
|
|
71
74
|
throw new BadRequestException(
|
|
72
75
|
'Query parameter "entity_type" is required',
|
|
@@ -83,7 +86,7 @@ export class EntityController {
|
|
|
83
86
|
if (entityService) {
|
|
84
87
|
return res
|
|
85
88
|
.status(HttpStatus.OK)
|
|
86
|
-
.json(await entityService.createEntity(entityData, loggedInUser as UserData));
|
|
89
|
+
.json(await entityService.createEntity(entityData, loggedInUser as UserData,null,appcode));
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
|
|
@@ -93,10 +96,13 @@ export class EntityController {
|
|
|
93
96
|
@Body() entityData: BaseEntity,
|
|
94
97
|
@Query('entity_type') entityType: string,
|
|
95
98
|
@Res() response: Response,
|
|
96
|
-
@Req() req: Request & {user: any}
|
|
99
|
+
@Req() req: Request & { user: any },
|
|
97
100
|
) {
|
|
98
101
|
let requestedUser = req.user;
|
|
99
|
-
let loggedInUser = await this.entityService.getEntityData(
|
|
102
|
+
let loggedInUser = await this.entityService.getEntityData(
|
|
103
|
+
ENTITYTYPE_USER,
|
|
104
|
+
requestedUser.userId,
|
|
105
|
+
);
|
|
100
106
|
if (!entityType) {
|
|
101
107
|
throw new BadRequestException(
|
|
102
108
|
'Query parameter "entity_type" is required',
|
|
@@ -117,7 +123,10 @@ export class EntityController {
|
|
|
117
123
|
}
|
|
118
124
|
// let mergeEntity = JsonUtil.merge(existingEntity, entityData);
|
|
119
125
|
|
|
120
|
-
entityData = await entityService.updateEntity(
|
|
126
|
+
entityData = await entityService.updateEntity(
|
|
127
|
+
entityData,
|
|
128
|
+
loggedInUser as UserData,
|
|
129
|
+
);
|
|
121
130
|
return response.status(HttpStatus.OK).json(entityData);
|
|
122
131
|
}
|
|
123
132
|
}
|
|
@@ -127,6 +136,7 @@ export class EntityController {
|
|
|
127
136
|
@Param('entity_type') entityType: string,
|
|
128
137
|
@Query('list_type') listType: string,
|
|
129
138
|
@Res() res: Response,
|
|
139
|
+
@Request() req,
|
|
130
140
|
@Body() filters: Record<string, any> = {},
|
|
131
141
|
@Query('sort_column') sortColumn?: string,
|
|
132
142
|
@Query('sort_order') sortOrder?: string,
|
|
@@ -135,6 +145,8 @@ export class EntityController {
|
|
|
135
145
|
@Query('tab_column') tabColumn?: string,
|
|
136
146
|
@Query('tab_value') tabValue?: string,
|
|
137
147
|
) {
|
|
148
|
+
const appcode = req.user.appcode;
|
|
149
|
+
|
|
138
150
|
return res
|
|
139
151
|
.status(HttpStatus.OK)
|
|
140
152
|
.json(
|
|
@@ -147,7 +159,8 @@ export class EntityController {
|
|
|
147
159
|
page,
|
|
148
160
|
size,
|
|
149
161
|
tabColumn,
|
|
150
|
-
tabValue
|
|
162
|
+
tabValue,
|
|
163
|
+
appcode,
|
|
151
164
|
),
|
|
152
165
|
);
|
|
153
166
|
}
|
|
@@ -164,13 +177,12 @@ export class EntityController {
|
|
|
164
177
|
@Res() res: Response, // Express Response for file handling
|
|
165
178
|
) {
|
|
166
179
|
try {
|
|
167
|
-
|
|
168
180
|
const filePath = await this.entityService.generateExcelReport(
|
|
169
181
|
entityType,
|
|
170
182
|
filterCriteria,
|
|
171
183
|
listEntityType,
|
|
172
184
|
displayType,
|
|
173
|
-
sampleExport
|
|
185
|
+
sampleExport,
|
|
174
186
|
);
|
|
175
187
|
|
|
176
188
|
if (!filePath || !fs.existsSync(filePath)) {
|
|
@@ -181,7 +193,10 @@ export class EntityController {
|
|
|
181
193
|
'Content-Disposition',
|
|
182
194
|
`attachment; filename=${path.basename(filePath)}`,
|
|
183
195
|
);
|
|
184
|
-
res.setHeader(
|
|
196
|
+
res.setHeader(
|
|
197
|
+
'Content-Type',
|
|
198
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
199
|
+
);
|
|
185
200
|
|
|
186
201
|
const fileStream = fs.createReadStream(filePath);
|
|
187
202
|
fileStream.pipe(res);
|
|
@@ -25,6 +25,7 @@ export class EntityListService {
|
|
|
25
25
|
pageSize: number,
|
|
26
26
|
tabColumn?: string,
|
|
27
27
|
tabValue?: string,
|
|
28
|
+
appcode?: string,
|
|
28
29
|
): Promise<EntityListData> {
|
|
29
30
|
let entityListData = new EntityListData();
|
|
30
31
|
|
|
@@ -35,7 +36,11 @@ export class EntityListService {
|
|
|
35
36
|
|
|
36
37
|
if (entityTable) {
|
|
37
38
|
if (1 != entityTable.is_proc) {
|
|
38
|
-
let totalCount = await this.getTotalCount(
|
|
39
|
+
let totalCount = await this.getTotalCount(
|
|
40
|
+
entityTable,
|
|
41
|
+
filters,
|
|
42
|
+
appcode,
|
|
43
|
+
);
|
|
39
44
|
entityListData.entity_tabs = totalCount as EntityTab[];
|
|
40
45
|
|
|
41
46
|
if (tabColumn && tabValue) {
|
|
@@ -48,6 +53,7 @@ export class EntityListService {
|
|
|
48
53
|
sortOrder,
|
|
49
54
|
pageNumber,
|
|
50
55
|
pageSize,
|
|
56
|
+
appcode,
|
|
51
57
|
);
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -62,7 +68,13 @@ export class EntityListService {
|
|
|
62
68
|
sortOrder: string | undefined,
|
|
63
69
|
pageNumber: number | undefined,
|
|
64
70
|
pageSize: number | undefined,
|
|
71
|
+
appcode?: string,
|
|
65
72
|
) {
|
|
73
|
+
// Add appcode to filters if provided
|
|
74
|
+
if (appcode) {
|
|
75
|
+
filters = { ...filters, appcode };
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
let query = this.getQuery(entityTable.data_source, null);
|
|
67
79
|
let whereClause = await this.getWhereClause(entityTable, filters);
|
|
68
80
|
if (whereClause.query) {
|
|
@@ -80,31 +92,31 @@ export class EntityListService {
|
|
|
80
92
|
private async getTotalCount(
|
|
81
93
|
entityTable: EntityTable,
|
|
82
94
|
filters: Record<string, any>,
|
|
95
|
+
appcode?: string,
|
|
83
96
|
) {
|
|
84
97
|
let query = this.getQuery(entityTable.data_source, entityTable.tab_column);
|
|
85
|
-
let whereClause = await this.getWhereClause(entityTable, filters);
|
|
98
|
+
let whereClause = await this.getWhereClause(entityTable, filters, appcode);
|
|
86
99
|
if (whereClause.query) {
|
|
87
100
|
query += whereClause.query;
|
|
88
101
|
}
|
|
89
102
|
query += ' GROUP BY ' + entityTable.tab_column;
|
|
90
|
-
|
|
103
|
+
|
|
91
104
|
let tabs = await this.entityManager.query(query, whereClause.argumentList);
|
|
92
|
-
|
|
105
|
+
|
|
93
106
|
let all = 0;
|
|
94
107
|
for (const i in tabs) {
|
|
95
108
|
let tab = tabs[i] as EntityTab;
|
|
96
109
|
tab.tab_value = String(tab.tab_value).toUpperCase(); // Capitalize tab_value
|
|
97
110
|
all += parseInt(String(tab.tab_value_count));
|
|
98
111
|
}
|
|
99
|
-
|
|
112
|
+
|
|
100
113
|
let entityTab = new EntityTab();
|
|
101
114
|
entityTab.tab_value = 'ALL';
|
|
102
115
|
entityTab.tab_value_count = all;
|
|
103
116
|
tabs.push(entityTab);
|
|
104
|
-
|
|
117
|
+
|
|
105
118
|
return tabs.reverse();
|
|
106
119
|
}
|
|
107
|
-
|
|
108
120
|
|
|
109
121
|
private getQuery(source: string, groupByColumn: string | null) {
|
|
110
122
|
if (groupByColumn) {
|
|
@@ -119,6 +131,7 @@ export class EntityListService {
|
|
|
119
131
|
private async getWhereClause(
|
|
120
132
|
entityTable: EntityTable,
|
|
121
133
|
filterCriteria?: Record<string, any>,
|
|
134
|
+
appcode?: string,
|
|
122
135
|
) {
|
|
123
136
|
let query = ' WHERE 1=1 ';
|
|
124
137
|
const argsObjectList: any[] = [];
|
|
@@ -155,6 +168,15 @@ export class EntityListService {
|
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
170
|
|
|
171
|
+
// Explicitly check for appcode if provided
|
|
172
|
+
if (appcode) {
|
|
173
|
+
query += ` AND appcode = ?`;
|
|
174
|
+
argsObjectList.push(appcode);
|
|
175
|
+
} else if (filterCriteria && filterCriteria.appcode) {
|
|
176
|
+
query += ` AND appcode = ?`;
|
|
177
|
+
argsObjectList.push(filterCriteria.appcode);
|
|
178
|
+
}
|
|
179
|
+
|
|
158
180
|
return { query, argumentList: argsObjectList };
|
|
159
181
|
}
|
|
160
182
|
|
|
@@ -28,13 +28,13 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
28
28
|
@Inject() protected readonly entityListService: EntityListService;
|
|
29
29
|
@Inject() protected readonly loggingService: LoggingService;
|
|
30
30
|
@Inject()
|
|
31
|
-
protected readonly entityValidationService: EntityValidationService;
|
|
32
|
-
|
|
31
|
+
protected readonly entityValidationService: EntityValidationService;
|
|
33
32
|
|
|
34
33
|
async createEntity(
|
|
35
34
|
entityData: BaseEntity,
|
|
36
35
|
loggedInUser: UserData | null,
|
|
37
|
-
manager?: EntityManager,
|
|
36
|
+
manager?: EntityManager | null,
|
|
37
|
+
appcode?: string,
|
|
38
38
|
){
|
|
39
39
|
if (!entityData.entity_type) {
|
|
40
40
|
throw new BadRequestException(`EntityType is missing`);
|
|
@@ -43,14 +43,16 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
43
43
|
entityData.entity_type,
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const validationErrors =
|
|
46
|
+
const validationErrors =
|
|
47
|
+
await this.entityValidationService.validateEntityData(
|
|
48
|
+
entityData,
|
|
49
|
+
entityMaster,
|
|
50
|
+
);
|
|
47
51
|
if (validationErrors.length > 0) {
|
|
48
|
-
|
|
49
|
-
return {
|
|
52
|
+
return {
|
|
50
53
|
success: false,
|
|
51
54
|
errors: validationErrors,
|
|
52
55
|
};
|
|
53
|
-
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
const repo = manager
|
|
@@ -127,24 +129,32 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
127
129
|
return await repoService.findOne({ where: { id: id } });
|
|
128
130
|
}
|
|
129
131
|
|
|
130
|
-
async getEntityList(
|
|
132
|
+
async getEntityList(
|
|
133
|
+
entityType: string,
|
|
134
|
+
filters: Record<string, any> = {},
|
|
135
|
+
): Promise<BaseEntity[]> {
|
|
131
136
|
const entityData = await this.entityMasterService.getEntityData(entityType);
|
|
132
|
-
const repoService = this.reflectionHelper.getRepoService(
|
|
133
|
-
|
|
137
|
+
const repoService = this.reflectionHelper.getRepoService(
|
|
138
|
+
entityData.entity_data_class,
|
|
139
|
+
);
|
|
140
|
+
|
|
134
141
|
if (!repoService) {
|
|
135
|
-
throw new Error(
|
|
142
|
+
throw new Error(
|
|
143
|
+
`Repository service not found for entityType: ${entityType}`,
|
|
144
|
+
);
|
|
136
145
|
}
|
|
137
|
-
|
|
146
|
+
|
|
138
147
|
const result = await repoService.find({
|
|
139
148
|
where: filters,
|
|
140
149
|
});
|
|
141
|
-
|
|
150
|
+
|
|
142
151
|
return result;
|
|
143
152
|
}
|
|
144
|
-
|
|
153
|
+
|
|
145
154
|
async updateEntity(
|
|
146
155
|
entityData: BaseEntity,
|
|
147
156
|
loggedInUser: UserData | null,
|
|
157
|
+
appcode?: string,
|
|
148
158
|
): Promise<BaseEntity> {
|
|
149
159
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
150
160
|
entityData.entity_type,
|
|
@@ -181,6 +191,7 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
181
191
|
pageSize: number,
|
|
182
192
|
tabColumn?: string,
|
|
183
193
|
tabValue?: string,
|
|
194
|
+
appcode?: string,
|
|
184
195
|
): Promise<EntityListData> {
|
|
185
196
|
return await this.entityListService.getFilterDataWithTabs(
|
|
186
197
|
entityType,
|
|
@@ -191,7 +202,8 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
191
202
|
pageNumber,
|
|
192
203
|
pageSize,
|
|
193
204
|
tabColumn,
|
|
194
|
-
tabValue
|
|
205
|
+
tabValue,
|
|
206
|
+
appcode,
|
|
195
207
|
);
|
|
196
208
|
}
|
|
197
209
|
|
|
@@ -211,7 +223,7 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
211
223
|
filterCriteria,
|
|
212
224
|
listEntityType,
|
|
213
225
|
displayType,
|
|
214
|
-
sampleExport
|
|
226
|
+
sampleExport,
|
|
215
227
|
);
|
|
216
228
|
|
|
217
229
|
const modifiedDate = new Date().toISOString().replace(/[-T:.Z]/g, '');
|
|
@@ -261,7 +273,7 @@ protected readonly entityValidationService: EntityValidationService;
|
|
|
261
273
|
);
|
|
262
274
|
|
|
263
275
|
let filteredList: any[] = [];
|
|
264
|
-
if(!sampleExport) {
|
|
276
|
+
if (!sampleExport) {
|
|
265
277
|
filteredList = await this.entityListService.getFilteredList(
|
|
266
278
|
entityTable,
|
|
267
279
|
filterCriteria,
|
|
@@ -8,6 +8,7 @@ export interface EntityService<T extends BaseEntity> {
|
|
|
8
8
|
entityData: T,
|
|
9
9
|
loggedInUser: UserData,
|
|
10
10
|
manager?: EntityManager,
|
|
11
|
+
appcode?: string,
|
|
11
12
|
): Promise<BaseEntity>;
|
|
12
13
|
|
|
13
14
|
getEntityData(
|
|
@@ -17,7 +18,7 @@ export interface EntityService<T extends BaseEntity> {
|
|
|
17
18
|
|
|
18
19
|
getEntityList(entityType: string): Promise<BaseEntity[]>;
|
|
19
20
|
|
|
20
|
-
updateEntity(entityData: T, loggedInUserData: UserData): Promise<BaseEntity>;
|
|
21
|
+
updateEntity(entityData: T, loggedInUserData: UserData,app_code?:string): Promise<BaseEntity>;
|
|
21
22
|
|
|
22
23
|
deleteEntity(
|
|
23
24
|
entityType: string,
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
Body,
|
|
4
|
+
Controller,
|
|
5
|
+
Get,
|
|
6
|
+
Inject,
|
|
7
|
+
Param,
|
|
8
|
+
Post,
|
|
9
|
+
Query,
|
|
10
|
+
Req,
|
|
11
|
+
Request,
|
|
12
|
+
UseGuards,
|
|
13
|
+
} from '@nestjs/common';
|
|
2
14
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
3
15
|
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
4
16
|
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
@@ -9,52 +21,67 @@ import { MenuRepository } from '../repository/menu.repository';
|
|
|
9
21
|
@Controller('module-access')
|
|
10
22
|
@UseGuards(JwtAuthGuard)
|
|
11
23
|
export class ModuleAccessController {
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly moduleAccessService: ModuleAccessService,
|
|
26
|
+
private readonly menuRepository: MenuRepository,
|
|
14
27
|
) {}
|
|
15
28
|
|
|
16
29
|
@Get('roles')
|
|
17
|
-
async getRoles() {
|
|
18
|
-
|
|
30
|
+
async getRoles(@Request() req) {
|
|
31
|
+
const appcode = req.user.appcode;
|
|
32
|
+
return this.moduleAccessService.getRoles({ appcode });
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
@Get('modules')
|
|
22
|
-
async getModules() {
|
|
23
|
-
|
|
36
|
+
async getModules(@Request() req) {
|
|
37
|
+
const appcode = req.user.appcode;
|
|
38
|
+
|
|
39
|
+
return this.moduleAccessService.getModules({
|
|
40
|
+
appcode,
|
|
41
|
+
});
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
@Get('access-listing')
|
|
27
|
-
async getAccessListing(@Query('roles') roleIds: string) {
|
|
45
|
+
async getAccessListing(@Query('roles') roleIds: string, @Request() req) {
|
|
28
46
|
const roleIdArray = roleIds.split(',').map(Number);
|
|
29
|
-
|
|
47
|
+
const appcode = req.user.appcode;
|
|
48
|
+
return this.moduleAccessService.getAccessListing(roleIdArray, appcode);
|
|
30
49
|
}
|
|
31
50
|
|
|
32
51
|
@Get('menu-listing')
|
|
33
|
-
async getMenuListing(@Query('mainmod') mainModIds: string) {
|
|
52
|
+
async getMenuListing(@Query('mainmod') mainModIds: string, @Request() req) {
|
|
34
53
|
const mainModArray = mainModIds.split(',').map(String);
|
|
35
|
-
|
|
54
|
+
const appcode = req.user.appcode;
|
|
55
|
+
return this.moduleAccessService.getMenuListing(mainModArray, appcode);
|
|
36
56
|
}
|
|
37
57
|
|
|
38
58
|
@Post('update')
|
|
39
|
-
async updateModuleAccess(@Body() moduleAccessData: any[]) {
|
|
40
|
-
|
|
59
|
+
async updateModuleAccess(@Body() moduleAccessData: any[], @Request() req) {
|
|
60
|
+
const appcode = req.user.appcode;
|
|
61
|
+
return this.moduleAccessService.updateModuleAccess(
|
|
62
|
+
moduleAccessData,
|
|
63
|
+
appcode,
|
|
64
|
+
);
|
|
41
65
|
}
|
|
42
66
|
|
|
43
67
|
// src/module/module-access/controller/module-access.controller.ts
|
|
44
68
|
|
|
45
69
|
@Get('ui-config')
|
|
46
|
-
async getModuleUIConfig(
|
|
70
|
+
async getModuleUIConfig(
|
|
71
|
+
@Query('module_code') moduleCode: string,
|
|
72
|
+
@Request() req,
|
|
73
|
+
) {
|
|
47
74
|
const userId = req.user.userId;
|
|
48
75
|
const appcode = req.user.appcode;
|
|
49
|
-
const roles = await this.menuRepository.getUserRoles(userId,appcode); // returns ['1', '4']
|
|
50
|
-
|
|
76
|
+
const roles = await this.menuRepository.getUserRoles(userId, appcode); // returns ['1', '4']
|
|
77
|
+
|
|
51
78
|
if (!roles || roles.length === 0) {
|
|
52
79
|
throw new BadRequestException('User has no roles');
|
|
53
80
|
}
|
|
54
|
-
|
|
55
|
-
return this.moduleAccessService.getModuleUIConfig(moduleCode, roles.map(id => Number(id)));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
81
|
|
|
82
|
+
return this.moduleAccessService.getModuleUIConfig(
|
|
83
|
+
moduleCode,
|
|
84
|
+
roles.map((id) => Number(id)),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
60
87
|
}
|