rez_core 1.0.63 → 1.0.65

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.
Files changed (61) hide show
  1. package/dist/constant/global.constant.d.ts +3 -0
  2. package/dist/constant/global.constant.js +4 -1
  3. package/dist/constant/global.constant.js.map +1 -1
  4. package/dist/module/auth/guards/role.guard.js +3 -3
  5. package/dist/module/master/controller/master.controller.d.ts +11 -1
  6. package/dist/module/master/controller/master.controller.js +42 -4
  7. package/dist/module/master/controller/master.controller.js.map +1 -1
  8. package/dist/module/master/service/master.service.d.ts +13 -4
  9. package/dist/module/master/service/master.service.js +97 -23
  10. package/dist/module/master/service/master.service.js.map +1 -1
  11. package/dist/module/meta/controller/meta.controller.d.ts +7 -0
  12. package/dist/module/meta/controller/meta.controller.js +47 -0
  13. package/dist/module/meta/controller/meta.controller.js.map +1 -0
  14. package/dist/module/meta/dto/entity-table.dto.d.ts +5 -0
  15. package/dist/module/meta/dto/entity-table.dto.js +8 -0
  16. package/dist/module/meta/dto/entity-table.dto.js.map +1 -0
  17. package/dist/module/meta/entity.module.js +2 -1
  18. package/dist/module/meta/entity.module.js.map +1 -1
  19. package/dist/module/meta/repository/entity-table-column.repository.js +1 -0
  20. package/dist/module/meta/repository/entity-table-column.repository.js.map +1 -1
  21. package/dist/module/meta/service/entity-table.service.d.ts +6 -1
  22. package/dist/module/meta/service/entity-table.service.js +18 -2
  23. package/dist/module/meta/service/entity-table.service.js.map +1 -1
  24. package/dist/tsconfig.build.tsbuildinfo +1 -1
  25. package/package.json +1 -1
  26. package/src/app.controller.ts +12 -12
  27. package/src/app.service.ts +8 -8
  28. package/src/constant/global.constant.ts +5 -0
  29. package/src/module/auth/guards/jwt.guard.ts +22 -22
  30. package/src/module/auth/guards/role.guard.ts +68 -68
  31. package/src/module/auth/services/jwt.service.ts +11 -11
  32. package/src/module/auth/strategies/local.strategy.ts +13 -13
  33. package/src/module/dev/dev.module.ts +12 -12
  34. package/src/module/dev/service/dev.service.ts +7 -7
  35. package/src/module/enterprise/entity/organization.entity.ts +80 -80
  36. package/src/module/master/controller/master.controller.ts +35 -11
  37. package/src/module/master/service/master.service.ts +144 -47
  38. package/src/module/meta/controller/meta.controller.ts +22 -0
  39. package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
  40. package/src/module/meta/dto/entity-table.dto.ts +6 -0
  41. package/src/module/meta/entity/preference.entity.ts +65 -65
  42. package/src/module/meta/entity.module.ts +2 -1
  43. package/src/module/meta/repository/entity-table-column.repository.ts +1 -0
  44. package/src/module/meta/repository/preference.repository.ts +20 -20
  45. package/src/module/meta/service/entity-table.service.ts +43 -3
  46. package/src/module/module/controller/menu.controller.ts +15 -15
  47. package/src/module/module/entity/module-access.entity.ts +22 -22
  48. package/src/module/user/controller/user.controller.ts +28 -28
  49. package/src/module/user/dto/update-user.dto.ts +4 -4
  50. package/src/module/user/entity/user-session.entity.ts +61 -61
  51. package/src/module/user/repository/userSession.repository.ts +33 -33
  52. package/src/utils/service/encryptUtil.service.ts +97 -97
  53. package/src/utils/service/excelUtil.service.ts +15 -15
  54. package/src/utils/service/reflection-helper.service.ts +53 -53
  55. package/.idea/250218_nodejs_core.iml +0 -12
  56. package/.idea/codeStyles/Project.xml +0 -59
  57. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  58. package/.idea/dataSources.xml +0 -12
  59. package/.idea/modules.xml +0 -8
  60. package/.idea/prettier.xml +0 -6
  61. package/.idea/vcs.xml +0 -6
@@ -1,16 +1,11 @@
1
1
  import { Injectable } from '@nestjs/common';
2
- import { EntityManager, Unique } from 'typeorm';
2
+ import { EntityManager } from 'typeorm';
3
3
  import { ExcelUtil } from 'src/utils/service/excelUtil.service';
4
4
  import { EntityMasterService } from '../../meta/service/entity-master.service';
5
- import { table } from 'console';
6
5
  import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
7
6
  import { EntityMaster } from 'src/module/meta/entity/entity-master.entity';
8
7
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
9
-
10
- interface ParentEntity {
11
- id: number;
12
- code: string;
13
- }
8
+ import { ReflectionHelper } from 'src/utils/service/reflection-helper.service';
14
9
 
15
10
  @Injectable()
16
11
  export class MasterService {
@@ -19,6 +14,8 @@ export class MasterService {
19
14
  private readonly entityMasterService: EntityMasterService,
20
15
  private readonly attributeMasterService: AttributeMasterService,
21
16
  private readonly excelUtil: ExcelUtil,
17
+ private reflectionHelper: ReflectionHelper,
18
+
22
19
  private readonly entityServiceImpl: EntityServiceImpl,
23
20
  ) {}
24
21
 
@@ -46,7 +43,6 @@ export class MasterService {
46
43
  unique_fields: ['listtype', 'code'],
47
44
  },
48
45
  ];
49
-
50
46
  private readonly dataSequence = [
51
47
  {
52
48
  table: 'cr_user',
@@ -70,43 +66,7 @@ export class MasterService {
70
66
  },
71
67
  ];
72
68
 
73
- private isMetaSheet(sheetName: string): boolean {
74
- return this.metaSheets.includes(sheetName.toLowerCase());
75
- }
76
-
77
- private async resolveParent(row: any): Promise<void> {
78
- const parentType = row.parent_type; // (Future use maybe)
79
- const code = row.parent_id;
80
-
81
- if (!code) {
82
- throw new Error('Parent code is missing in the row');
83
- }
84
-
85
- const parentEntity: EntityMaster | null =
86
- await this.entityMasterService.findByMappedEntityType(parentType);
87
-
88
- const tableName: any = parentEntity?.db_table_name;
89
- if (!tableName) {
90
- throw new Error(`Table name not found for parent type ${parentType}`);
91
- }
92
-
93
- // Using RAW SQL Query
94
- const entityData = await this.entityManager.query(
95
- `SELECT * FROM ${tableName} WHERE code = ? LIMIT 1`,
96
- [code],
97
- );
98
-
99
- if (!entityData || entityData.length === 0) {
100
- throw new Error(
101
- `Parent entity with code ${code} not found in table ${tableName}`,
102
- );
103
- }
104
-
105
- // entityData is an array when using .query()
106
- row.parent_id = entityData[0].id;
107
- }
108
-
109
- async uploadMasterData(file) {
69
+ async uploadMeta(file) {
110
70
  const data = ExcelUtil.readExcel(file.buffer);
111
71
 
112
72
  for (let i = 0; i < this.sequence.length; i++) {
@@ -122,6 +82,14 @@ export class MasterService {
122
82
  await this.upsertData(table, unique_fields, sheetData);
123
83
  }
124
84
  }
85
+ return {
86
+ message: 'Data uploaded successfully',
87
+ };
88
+ }
89
+
90
+ async uploadData(file) {
91
+ const data = ExcelUtil.readExcel(file.buffer);
92
+
125
93
  for (let i = 0; i < this.dataSequence.length; i++) {
126
94
  const { table, unique_fields } = this.dataSequence[i];
127
95
  const sheetData = data[table];
@@ -139,7 +107,6 @@ export class MasterService {
139
107
  entityMasterData?.mapped_entity_type,
140
108
  );
141
109
 
142
- console.log(attributes,"((((((((((((((((((((((((((")
143
110
  for (const row of sheetData) {
144
111
  if (row.parent_type !== undefined && row.parent_id !== undefined) {
145
112
  this.resolveParent(row);
@@ -147,7 +114,7 @@ export class MasterService {
147
114
 
148
115
  for (const attribute of attributes) {
149
116
  if (attribute.data_source_type === 'entity') {
150
- console.log(attribute.data_source_type)
117
+ console.log(attribute.data_source_type);
151
118
  let entityMaster = await this.entityMasterService.getEntityData(
152
119
  attribute.datasource_list,
153
120
  );
@@ -168,6 +135,95 @@ export class MasterService {
168
135
  };
169
136
  }
170
137
 
138
+ async uploadEntityData(file, entityType, loggedInUser) {
139
+ const data = ExcelUtil.readExcel(file.buffer);
140
+ const entityMaster = await this.entityMasterService.findByMappedEntityType(entityType);
141
+ if (!entityMaster) {
142
+ throw new Error(`Entity master not found for entityType: ${entityType}`);
143
+ }
144
+
145
+ const tableName = entityMaster.db_table_name;
146
+ const sheetData = data[tableName];
147
+
148
+ if (!sheetData) {
149
+ throw new Error(`Sheet for ${tableName} not found in uploaded file`);
150
+ }
151
+
152
+ const attributes = await this.attributeMasterService.findAttributesByMappedEntityType(entityType);
153
+
154
+ const uniqueFields = attributes
155
+ .filter(attr => attr.is_unique)
156
+ .map(attr => attr.attribute_key);
157
+
158
+ if (uniqueFields.length === 0) {
159
+ throw new Error(`No unique fields found for entityType: ${entityType}`);
160
+ }
161
+
162
+ // Transform reference fields
163
+ for (const row of sheetData) {
164
+ if (row.parent_type && row.parent_id) {
165
+ await this.resolveParent(row);
166
+ }
167
+
168
+ for (const attr of attributes) {
169
+ if (attr.data_source_type === 'entity' && row[attr.attribute_key]) {
170
+ const refEntity = await this.entityMasterService.getEntityData(attr.datasource_list);
171
+ const refData = await this.entityManager.query(
172
+ `SELECT * FROM ${refEntity.db_table_name} WHERE code = ? LIMIT 1`,
173
+ [row[attr.attribute_key]],
174
+ );
175
+
176
+ if (!refData.length) {
177
+ throw new Error(`Reference entity not found for code: ${row[attr.attribute_key]}`);
178
+ }
179
+
180
+ row[attr.attribute_key] = refData[0].id;
181
+ }
182
+ }
183
+ }
184
+
185
+ await this.upsertViaService(entityType, sheetData, attributes, uniqueFields, loggedInUser);
186
+
187
+ return { message: 'Entity data uploaded successfully' };
188
+ }
189
+
190
+
191
+ private isMetaSheet(sheetName: string): boolean {
192
+ return this.metaSheets.includes(sheetName.toLowerCase());
193
+ }
194
+
195
+ private async resolveParent(row: any): Promise<void> {
196
+ const parentType = row.parent_type; // (Future use maybe)
197
+ const code = row.parent_id;
198
+
199
+ if (!code) {
200
+ throw new Error('Parent code is missing in the row');
201
+ }
202
+
203
+ const parentEntity: EntityMaster | null =
204
+ await this.entityMasterService.findByMappedEntityType(parentType);
205
+
206
+ const tableName: any = parentEntity?.db_table_name;
207
+ if (!tableName) {
208
+ throw new Error(`Table name not found for parent type ${parentType}`);
209
+ }
210
+
211
+ // Using RAW SQL Query
212
+ const entityData = await this.entityManager.query(
213
+ `SELECT * FROM ${tableName} WHERE code = ? LIMIT 1`,
214
+ [code],
215
+ );
216
+
217
+ if (!entityData || entityData.length === 0) {
218
+ throw new Error(
219
+ `Parent entity with code ${code} not found in table ${tableName}`,
220
+ );
221
+ }
222
+
223
+ // entityData is an array when using .query()
224
+ row.parent_id = entityData[0].id;
225
+ }
226
+
171
227
  async upsertData(
172
228
  tableName: string,
173
229
  uniqueFields: string[],
@@ -210,4 +266,45 @@ export class MasterService {
210
266
  }
211
267
  }
212
268
  }
269
+
270
+ async upsertViaService(
271
+ entityType: string,
272
+ data: any[],
273
+ attributes: any[],
274
+ uniqueFields: string[],
275
+ loggedInUser: any,
276
+ ): Promise<void> {
277
+ const entityMaster = await this.entityMasterService.findByMappedEntityType(entityType);
278
+ if (!entityMaster) throw new Error(`Entity master not found for ${entityType}`);
279
+
280
+ const serviceName = entityMaster.entity_service;
281
+ const entityService = await this.reflectionHelper.getBean<EntityServiceImpl>(serviceName);
282
+
283
+ if (!entityService) throw new Error(`Entity service not found for ${entityType}`);
284
+
285
+ for (const row of data) {
286
+ const whereClause = uniqueFields.reduce((acc, field) => {
287
+ acc[field] = row[field];
288
+ return acc;
289
+ }, {});
290
+
291
+ const existing = await this.entityManager
292
+ .createQueryBuilder()
293
+ .select('*')
294
+ .from(entityMaster.db_table_name, entityMaster.db_table_name)
295
+ .where(whereClause)
296
+ .limit(1)
297
+ .getRawOne();
298
+
299
+ row.entity_type = entityType;
300
+ if (existing) {
301
+ row.id = existing.id;
302
+ await entityService.updateEntity(row, loggedInUser);
303
+ } else {
304
+ await entityService.createEntity(row, loggedInUser);
305
+ }
306
+ }
307
+ }
308
+
309
+
213
310
  }
@@ -0,0 +1,22 @@
1
+ import { Controller, HttpStatus, Post, Query, Res, UseGuards } from '@nestjs/common';
2
+ import { EntityTableService } from '../service/entity-table.service';
3
+ import { Response } from 'express';
4
+ import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
5
+
6
+ @Controller('meta')
7
+ @UseGuards(JwtAuthGuard)
8
+ export class MetaController {
9
+ constructor(private readonly entityTableService: EntityTableService) {}
10
+
11
+ @Post('get-table-data')
12
+ async getTableMetaData(@Query('entity_type') entityType: string,
13
+ @Query('list_type') listType: string,
14
+ @Res() response: Response) {
15
+ let entityTableDto = await this.entityTableService.getTableMetaDataForListing(entityType, listType);
16
+ return response.status(HttpStatus.OK).json({
17
+ success: true,
18
+ data: entityTableDto,
19
+ message: 'Data fetch successfully!'
20
+ })
21
+ }
22
+ }
@@ -1,6 +1,6 @@
1
- import { EntityTab } from './entity-tab.dto';
2
-
3
- export class EntityListData {
4
- entity_list: any;
5
- entity_tabs: EntityTab[];
6
- }
1
+ import { EntityTab } from './entity-tab.dto';
2
+
3
+ export class EntityListData {
4
+ entity_list: any;
5
+ entity_tabs: EntityTab[];
6
+ }
@@ -0,0 +1,6 @@
1
+ import { EntityTable } from '../entity/entity-table.entity';
2
+ import { EntityTableColumn } from '../entity/entity-table-column.entity';
3
+
4
+ export class EntityTableDto extends EntityTable{
5
+ column_list: EntityTableColumn[];
6
+ }
@@ -1,65 +1,65 @@
1
- import { BaseEntity } from './base-entity.entity';
2
- import { Column, Entity } from 'typeorm';
3
- import { ENTITYTYPE_PREFERENCEMASTER } from '../../../constant/global.constant';
4
-
5
- @Entity({ name: 'cr_preference_master' })
6
- export class PreferenceMaster extends BaseEntity {
7
- constructor() {
8
- super();
9
- this.entity_type = ENTITYTYPE_PREFERENCEMASTER;
10
- }
11
-
12
- @Column({ name: 'appcode', type: 'varchar', length: 200, nullable: true })
13
- appCode: string;
14
-
15
- @Column({
16
- name: 'display_name',
17
- type: 'varchar',
18
- length: 200,
19
- nullable: true,
20
- })
21
- display_name: string;
22
-
23
- @Column({
24
- name: 'preference_key',
25
- type: 'varchar',
26
- length: 200,
27
- nullable: true,
28
- })
29
- preference_key: string;
30
-
31
- @Column({
32
- name: 'preference_value',
33
- type: 'varchar',
34
- length: 200,
35
- nullable: true,
36
- })
37
- preference_value: string;
38
-
39
- @Column({
40
- name: 'description',
41
- type: 'varchar',
42
- length: 2000,
43
- nullable: true,
44
- })
45
- description: string;
46
-
47
- @Column({ name: 'reflect_on', type: 'varchar', length: 200, nullable: true })
48
- reflect_on: string;
49
-
50
- @Column({
51
- name: 'default_value',
52
- type: 'varchar',
53
- length: 200,
54
- nullable: true,
55
- })
56
- default_value: string;
57
-
58
- @Column({
59
- name: 'possible_values',
60
- type: 'varchar',
61
- length: 200,
62
- nullable: true,
63
- })
64
- possible_values: string;
65
- }
1
+ import { BaseEntity } from './base-entity.entity';
2
+ import { Column, Entity } from 'typeorm';
3
+ import { ENTITYTYPE_PREFERENCEMASTER } from '../../../constant/global.constant';
4
+
5
+ @Entity({ name: 'cr_preference_master' })
6
+ export class PreferenceMaster extends BaseEntity {
7
+ constructor() {
8
+ super();
9
+ this.entity_type = ENTITYTYPE_PREFERENCEMASTER;
10
+ }
11
+
12
+ @Column({ name: 'appcode', type: 'varchar', length: 200, nullable: true })
13
+ appCode: string;
14
+
15
+ @Column({
16
+ name: 'display_name',
17
+ type: 'varchar',
18
+ length: 200,
19
+ nullable: true,
20
+ })
21
+ display_name: string;
22
+
23
+ @Column({
24
+ name: 'preference_key',
25
+ type: 'varchar',
26
+ length: 200,
27
+ nullable: true,
28
+ })
29
+ preference_key: string;
30
+
31
+ @Column({
32
+ name: 'preference_value',
33
+ type: 'varchar',
34
+ length: 200,
35
+ nullable: true,
36
+ })
37
+ preference_value: string;
38
+
39
+ @Column({
40
+ name: 'description',
41
+ type: 'varchar',
42
+ length: 2000,
43
+ nullable: true,
44
+ })
45
+ description: string;
46
+
47
+ @Column({ name: 'reflect_on', type: 'varchar', length: 200, nullable: true })
48
+ reflect_on: string;
49
+
50
+ @Column({
51
+ name: 'default_value',
52
+ type: 'varchar',
53
+ length: 200,
54
+ nullable: true,
55
+ })
56
+ default_value: string;
57
+
58
+ @Column({
59
+ name: 'possible_values',
60
+ type: 'varchar',
61
+ length: 200,
62
+ nullable: true,
63
+ })
64
+ possible_values: string;
65
+ }
@@ -34,6 +34,7 @@ import { FieldGroupService } from './service/field-group.service';
34
34
  import { ViewMasterService } from './service/view-master.service';
35
35
  import { ViewMasterController } from './controller/view-master.controller';
36
36
  import { ViewMaterRespository } from './repository/view-master.repository';
37
+ import { MetaController } from './controller/meta.controller';
37
38
 
38
39
  @Module({
39
40
  imports: [
@@ -84,6 +85,6 @@ import { ViewMaterRespository } from './repository/view-master.repository';
84
85
  FieldGroupService,
85
86
  'ViewMasterService',
86
87
  ],
87
- controllers: [EntityController, MasterController, MediaController, ViewMasterController],
88
+ controllers: [EntityController, MasterController, MediaController, ViewMasterController, MetaController],
88
89
  })
89
90
  export class EntityModule {}
@@ -16,6 +16,7 @@ export class EntityTableColumnRepository {
16
16
  parent_id: parentId,
17
17
  parent_type: parentType,
18
18
  },
19
+ order: { col_position: 'ASC' }
19
20
  });
20
21
  }
21
22
  }
@@ -1,20 +1,20 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectRepository } from '@nestjs/typeorm';
3
- import { PreferenceMaster } from '../entity/preference.entity';
4
- import { Repository } from 'typeorm';
5
-
6
- @Injectable()
7
- export class PreferenceRepository {
8
- constructor(
9
- @InjectRepository(PreferenceMaster)
10
- private readonly preferenceRepository: Repository<PreferenceMaster>,
11
- ) {}
12
-
13
- async findByPreferenceKey(
14
- preferenceKey: string,
15
- ): Promise<PreferenceMaster | null> {
16
- return await this.preferenceRepository.findOne({
17
- where: { preference_key: preferenceKey },
18
- });
19
- }
20
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { PreferenceMaster } from '../entity/preference.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class PreferenceRepository {
8
+ constructor(
9
+ @InjectRepository(PreferenceMaster)
10
+ private readonly preferenceRepository: Repository<PreferenceMaster>,
11
+ ) {}
12
+
13
+ async findByPreferenceKey(
14
+ preferenceKey: string,
15
+ ): Promise<PreferenceMaster | null> {
16
+ return await this.preferenceRepository.findOne({
17
+ where: { preference_key: preferenceKey },
18
+ });
19
+ }
20
+ }
@@ -1,9 +1,15 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { EntityTableRepository } from '../repository/entity-table.repository';
3
+ import { EntityTableColumnRepository } from '../repository/entity-table-column.repository';
4
+ import { EntityTableDto } from '../dto/entity-table.dto';
5
+ import { DISPLAY_LIST } from '../../../constant/global.constant';
3
6
 
4
7
  @Injectable()
5
8
  export class EntityTableService {
6
- constructor(private entityTableRepository: EntityTableRepository) {}
9
+ constructor(
10
+ private entityTableRepository: EntityTableRepository,
11
+ private readonly entityTableColumnRepository: EntityTableColumnRepository,
12
+ ) {}
7
13
 
8
14
  async findByEntityTypeAndListType(entityType: string, listType: string) {
9
15
  return await this.entityTableRepository.findByEntityTypeAndListType(
@@ -12,7 +18,41 @@ export class EntityTableService {
12
18
  );
13
19
  }
14
20
 
15
- async findByEntityTypeAndListTypeAndDisplayType(entityType: string, listType: string, displayType: string) {
16
- return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(entityType, listType, displayType);
21
+ async findByEntityTypeAndListTypeAndDisplayType(
22
+ entityType: string,
23
+ listType: string,
24
+ displayType: string,
25
+ ) {
26
+ return await this.entityTableRepository.findByEntityTypeAndListTypeAndDisplayType(
27
+ entityType,
28
+ listType,
29
+ displayType,
30
+ );
31
+ }
32
+
33
+ async getTableMetaDataForListing(entityType: string, listType: string) {
34
+ return await this.getTableMetaData(entityType, listType, DISPLAY_LIST);
35
+ }
36
+
37
+ async getTableMetaData(
38
+ entityType: string,
39
+ listType: string,
40
+ displayType: string,
41
+ ) {
42
+ let entityTable = await this.findByEntityTypeAndListTypeAndDisplayType(
43
+ entityType,
44
+ listType,
45
+ displayType,
46
+ );
47
+
48
+ let entityTableDto = entityTable as EntityTableDto;
49
+ if (entityTable) {
50
+ entityTableDto.column_list =
51
+ await this.entityTableColumnRepository.findByParentIdAndParentType(
52
+ entityTable.id,
53
+ entityTable.entity_type,
54
+ );
55
+ }
56
+ return entityTableDto;
17
57
  }
18
58
  }
@@ -1,15 +1,15 @@
1
- import { Controller, Get, Request, UseGuards } from '@nestjs/common';
2
- import { MenuService } from '../service/menu.service';
3
- import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
4
-
5
- @Controller('menu')
6
- export class MenuController {
7
- constructor(private readonly menuService: MenuService) {}
8
-
9
- @UseGuards(JwtAuthGuard)
10
- @Get()
11
- async getMenu(@Request() req) {
12
- const userId = req.user.userId;
13
- return this.menuService.getUserMenu(userId);
14
- }
15
- }
1
+ import { Controller, Get, Request, UseGuards } from '@nestjs/common';
2
+ import { MenuService } from '../service/menu.service';
3
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
4
+
5
+ @Controller('menu')
6
+ export class MenuController {
7
+ constructor(private readonly menuService: MenuService) {}
8
+
9
+ @UseGuards(JwtAuthGuard)
10
+ @Get()
11
+ async getMenu(@Request() req) {
12
+ const userId = req.user.userId;
13
+ return this.menuService.getUserMenu(userId);
14
+ }
15
+ }
@@ -1,22 +1,22 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_module_access' })
4
- export class ModuleAccess {
5
- @PrimaryGeneratedColumn()
6
- id: number;
7
-
8
- @Column({type: 'varchar', length: 100, nullable: true})
9
- module_code: string;
10
-
11
- @Column({type: 'varchar', length: 100, nullable: true })
12
- role_code: string;
13
-
14
- @Column({type: 'int', nullable: true })
15
- access_flag: number;
16
-
17
- @Column({type: 'varchar', length: 100, nullable: true })
18
- action_type: string;
19
-
20
- @Column({type: 'varchar', length: 100, nullable: true})
21
- app_code: string;
22
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_module_access' })
4
+ export class ModuleAccess {
5
+ @PrimaryGeneratedColumn()
6
+ id: number;
7
+
8
+ @Column({type: 'varchar', length: 100, nullable: true})
9
+ module_code: string;
10
+
11
+ @Column({type: 'varchar', length: 100, nullable: true })
12
+ role_code: string;
13
+
14
+ @Column({type: 'int', nullable: true })
15
+ access_flag: number;
16
+
17
+ @Column({type: 'varchar', length: 100, nullable: true })
18
+ action_type: string;
19
+
20
+ @Column({type: 'varchar', length: 100, nullable: true})
21
+ app_code: string;
22
+ }