rez_core 6.5.14 → 6.5.15

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": "6.5.14",
3
+ "version": "6.5.15",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -14,8 +14,6 @@ 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';
18
- import { EntityModule } from '../meta/entity.module';
19
17
 
20
18
  @Module({
21
19
  imports: [
@@ -29,15 +27,15 @@ import { EntityModule } from '../meta/entity.module';
29
27
  ]),
30
28
  UtilsModule,
31
29
  UserModule,
32
- EntityModule
33
30
  ],
34
31
  controllers: [MenuController, ModuleAccessController],
35
32
  providers: [
36
33
  ModuleAccessService,
37
34
  MenuService,
38
35
  MenuRepository,
39
- ModuleAccessRepository
36
+ ModuleAccessRepository,
40
37
  ],
41
38
  exports: [ModuleAccessService,MenuService],
42
39
  })
43
- export class ModuleAccessModule { }
40
+ export class ModuleAccessModule {
41
+ }
@@ -1,37 +1,32 @@
1
1
  import { BadRequestException, Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { In, Not, Repository, Or, DataSource, IsNull } from 'typeorm';
3
+ import { In, IsNull, Not, Or, Repository } from 'typeorm';
4
4
  import { Role } from 'src/module/user/entity/role.entity';
5
5
  import { ModuleAccess } from '../entity/module-access.entity';
6
6
  import { ModuleAction } from '../entity/module-action.entity';
7
7
  import { ModuleData } from '../entity/module.entity';
8
- import { AppMasterRespository } from '../../meta/repository/app-master.repository';
8
+ import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
9
9
 
10
10
  @Injectable()
11
11
  export class ModuleAccessRepository {
12
12
  constructor(
13
13
  @InjectRepository(Role)
14
14
  private readonly roleRepo: Repository<Role>,
15
-
16
15
  @InjectRepository(ModuleData)
17
16
  private readonly moduleRepo: Repository<ModuleData>,
18
-
19
17
  @InjectRepository(ModuleAccess)
20
18
  private readonly moduleAccessRepo: Repository<ModuleAccess>,
21
-
22
19
  @InjectRepository(ModuleAction)
23
20
  private readonly moduleActionRepo: Repository<ModuleAction>,
24
-
25
- private readonly appMasterRepo: AppMasterRespository,
26
-
27
- private readonly dataSource: DataSource,
28
- ) {}
21
+ private readonly reflectionHelper: ReflectionHelper,
22
+ ) {
23
+ }
29
24
 
30
25
  async getRoles({
31
- appcode,
32
- level_type,
33
- level_id,
34
- }: {
26
+ appcode,
27
+ level_type,
28
+ level_id,
29
+ }: {
35
30
  appcode: string;
36
31
  level_type?: string;
37
32
  level_id?: number;
@@ -63,26 +58,30 @@ export class ModuleAccessRepository {
63
58
  }
64
59
 
65
60
  async getModules({
66
- appcode,
67
- loggedInUser,
68
- }: {
61
+ appcode,
62
+ loggedInUser,
63
+ }: {
69
64
  appcode: string;
70
65
  loggedInUser: any;
71
66
  }) {
72
67
  let modules: any[];
73
68
  if (loggedInUser.level_type == 'SCH') {
74
69
  modules = await this.moduleRepo.find({
75
- where: { module_level: 'MAINMOD',
70
+ where: {
71
+ module_level: 'MAINMOD',
76
72
  app: {
77
- code: appcode
73
+ code: appcode,
78
74
  },
79
- level_type: 'SCH'
75
+ level_type: 'SCH',
80
76
  },
81
77
  });
82
78
  } else {
83
79
  modules = await this.moduleRepo.find({
84
- where: { module_level: 'MAINMOD', app : {code: appcode
85
- } },
80
+ where: {
81
+ module_level: 'MAINMOD', app: {
82
+ code: appcode,
83
+ },
84
+ },
86
85
  });
87
86
  }
88
87
 
@@ -116,7 +115,7 @@ export class ModuleAccessRepository {
116
115
  where: {
117
116
  id: In(fetchedRoleIds),
118
117
  app: {
119
- code: appcode
118
+ code: appcode,
120
119
  },
121
120
  },
122
121
  });
@@ -125,7 +124,7 @@ export class ModuleAccessRepository {
125
124
  where: {
126
125
  id: In(roleIds.map((id) => Number(id))),
127
126
  app: {
128
- code: appcode
127
+ code: appcode,
129
128
  },
130
129
  },
131
130
  });
@@ -137,14 +136,14 @@ export class ModuleAccessRepository {
137
136
  where: {
138
137
  role_id: In(roles.map((role) => role.id)),
139
138
  app: {
140
- code: appcode
139
+ code: appcode,
141
140
  },
142
- level_type: levelType
141
+ level_type: levelType,
143
142
  },
144
143
  relations: {
145
144
  app: true,
146
- module: true
147
- }
145
+ module: true,
146
+ },
148
147
  });
149
148
 
150
149
  return roles.map((role) => ({
@@ -159,13 +158,19 @@ export class ModuleAccessRepository {
159
158
  level_type: access.level_type,
160
159
  app_id: access.app_id,
161
160
  code: access.module.module_code,
162
- appcode: access.app.code
161
+ appcode: access.app.code,
163
162
  })),
164
163
  }));
165
164
  }
166
165
 
167
166
  async getAllModulesByLevel(mainModIds: string[], appcode: string, levelType) {
168
- const appMaster = await this.appMasterRepo.getAppMasterDataByAppCode(appcode);
167
+ const appMasterRepo = this.reflectionHelper.getRepoService('AppMaster');
168
+
169
+ const appMaster = await appMasterRepo.find({
170
+ where: {
171
+ code: appcode
172
+ }
173
+ });
169
174
 
170
175
  if (!appMaster) {
171
176
  return {};
@@ -175,10 +180,10 @@ export class ModuleAccessRepository {
175
180
  mainModIds.length === 1 && mainModIds[0] === '-1'
176
181
  ? await this.moduleRepo.find({
177
182
  where: { module_level: 'MAINMOD', app_id: appMaster[0].id },
178
- })
183
+ })
179
184
  : await this.moduleRepo.find({
180
- where: { id: In(mainModIds), module_level: 'MAINMOD', app: {code: appcode} },
181
- });
185
+ where: { id: In(mainModIds), module_level: 'MAINMOD', app: { code: appcode } },
186
+ });
182
187
 
183
188
  if (!mainModules.length) return {};
184
189
 
@@ -242,7 +247,7 @@ export class ModuleAccessRepository {
242
247
  (mod) =>
243
248
  mod.wbs_code.startsWith(`${parentWbs}.`) &&
244
249
  mod.wbs_code.split('.').length ===
245
- parentWbs.split('.').length + 1,
250
+ parentWbs.split('.').length + 1,
246
251
  )
247
252
  .map((mod) => ({
248
253
  name: mod.name,
@@ -287,11 +292,11 @@ export class ModuleAccessRepository {
287
292
  code: access.role_code,
288
293
  },
289
294
  module: {
290
- module_code: access.module_code
295
+ module_code: access.module_code,
291
296
  },
292
297
  action_type: access.action_type,
293
298
  app: {
294
- code: access.appcode
299
+ code: access.appcode,
295
300
  },
296
301
  level_type: access.level_type,
297
302
  },