rez_core 2.0.28 → 2.0.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.0.28",
3
+ "version": "2.0.30",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -110,6 +110,7 @@ export class EntityController {
110
110
  @Req() req: Request & { user: any },
111
111
  ) {
112
112
  let loggedInUser = req.user.userData;
113
+ console.log(loggedInUser," loggedInUser");
113
114
  // let loggedInUser = await this.entityService.getEntityData(
114
115
  // ENTITYTYPE_USER,
115
116
  // requestedUser.userId,
@@ -120,16 +121,18 @@ export class EntityController {
120
121
  );
121
122
  }
122
123
 
124
+ console.log(entityType,"entityType");
123
125
  const entityMaster =
124
126
  await this.entityMasterService.getEntityData(entityType);
125
-
127
+ console.log(entityMaster, "entityMaster");
126
128
  const entityService =
127
129
  await this.reflectionHelper.getBean<EntityServiceImpl>(
128
130
  entityMaster.entity_service,
129
131
  );
130
-
132
+ console.log(entityService, "entityService");``
131
133
  if (entityService) {
132
134
  let existingEntity = await entityService.getEntityData(entityType, id);
135
+ console.log(existingEntity, "existingEntity");
133
136
  if (!existingEntity) {
134
137
  }
135
138
  // let mergeEntity = JsonUtil.merge(existingEntity, entityData);
@@ -117,10 +117,12 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
117
117
  id: number,
118
118
  ): Promise<BaseEntity | null> {
119
119
  const entityData = await this.entityMasterService.getEntityData(entityType);
120
+ console.log(entityData, 'entityData in getEntityData');
120
121
 
121
122
  const repoService = this.reflectionHelper.getRepoService(
122
123
  entityData.entity_data_class,
123
124
  );
125
+ console.log(repoService, 'repoService in getEntityData');
124
126
  if (!repoService) {
125
127
  throw new Error(
126
128
  `Repository service not found for entityType: ${entityType}`,
@@ -17,13 +17,14 @@ import { ENTITYTYPE_USER } from '../../../constant/global.constant';
17
17
  import { UserService } from '../../user/service/user.service';
18
18
  import { UserData } from '../../user/entity/user.entity';
19
19
  import { MenuRepository } from '../repository/menu.repository';
20
+ import { MenuService } from '../service/menu.service';
20
21
 
21
22
  @Controller('module-access')
22
23
  @UseGuards(JwtAuthGuard)
23
24
  export class ModuleAccessController {
24
25
  constructor(
25
26
  private readonly moduleAccessService: ModuleAccessService,
26
- private readonly menuRepository: MenuRepository,
27
+ private readonly menuService: MenuService,
27
28
  ) {}
28
29
 
29
30
  @Get('roles')
@@ -73,7 +74,7 @@ export class ModuleAccessController {
73
74
  ) {
74
75
  const userId = req.user.userData?.id;
75
76
  const appcode = req.user.userData?.appcode;
76
- const roles = await this.menuRepository.getUserRoles(userId, appcode); // returns ['1', '4']
77
+ const roles = await this.menuService.getUserRoles(userId, appcode); // returns ['1', '4']
77
78
 
78
79
  if (!roles || roles.length === 0) {
79
80
  throw new BadRequestException('User has no roles');
@@ -9,22 +9,27 @@ export class MenuService {
9
9
  /**
10
10
  * Fetch and construct menu hierarchy for a given user.
11
11
  */
12
- async getUserMenu(userId: number,appcode:string): Promise<{ menu: any[] }> {
12
+ async getUserMenu(userId: number, appcode: string): Promise<{ menu: any[] }> {
13
13
  // Step 1: Get the roles of the user
14
- const roleCodes = await this.menuRepository.getUserRoles(userId,appcode);
14
+ const roleCodes = await this.menuRepository.getUserRoles(userId, appcode);
15
15
  if (!roleCodes.length) {
16
16
  return { menu: [] }; // Return empty menu if user has no roles
17
17
  }
18
18
 
19
19
  // Step 2: Get the modules the user has access to
20
- const moduleCodes =
21
- await this.menuRepository.getAccessibleModules(roleCodes,appcode);
20
+ const moduleCodes = await this.menuRepository.getAccessibleModules(
21
+ roleCodes,
22
+ appcode,
23
+ );
22
24
  if (!moduleCodes.length) {
23
25
  return { menu: [] }; // Return empty menu if no accessible modules
24
26
  }
25
27
 
26
28
  // Step 3: Get the menu items based on accessible modules
27
- const menuItems = await this.menuRepository.getMenuItems(moduleCodes,appcode);
29
+ const menuItems = await this.menuRepository.getMenuItems(
30
+ moduleCodes,
31
+ appcode,
32
+ );
28
33
 
29
34
  // Step 4: Build hierarchical menu structure
30
35
  const menuTree = this.buildMenuHierarchy(menuItems);
@@ -57,4 +62,9 @@ export class MenuService {
57
62
 
58
63
  return rootMenu;
59
64
  }
65
+
66
+ // get user roles
67
+ async getUserRoles(userId: number, appcode: string): Promise<any> {
68
+ return this.menuRepository.getUserRoles(userId, appcode);
69
+ }
60
70
  }