rez_core 2.1.71 → 2.1.73

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.1.71",
3
+ "version": "2.1.73",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -26,7 +26,12 @@ export class OrganizationController {
26
26
  async getOrganizationHierarchy(@Req() req: Request & { user: any }) {
27
27
  const userId = req.user.userData?.id;
28
28
  const appcode = req.user.userData?.appcode;
29
+ const org_id = req.user.userData?.organization_id;
29
30
 
30
- return await this.orgService.getOrganizationHierarchy(userId, appcode);
31
+ return await this.orgService.getOrganizationHierarchy(
32
+ userId,
33
+ appcode,
34
+ org_id,
35
+ );
31
36
  }
32
37
  }
@@ -24,7 +24,7 @@ export class SchoolRepository {
24
24
  });
25
25
  }
26
26
 
27
- async getUserContextDropdown(userId: number, appCode: string) {
27
+ async getUserContextDropdown(userId: number, appCode: string, org_id) {
28
28
  const userRoleRepo = this.dataSource.getRepository(UserRoleMapping);
29
29
 
30
30
  const hasOrgAccess = await userRoleRepo
@@ -34,6 +34,15 @@ export class SchoolRepository {
34
34
  .andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
35
35
  .getRawMany();
36
36
 
37
+ console.log('hasOrgAccess before', hasOrgAccess);
38
+
39
+ let currentORGLevel_id = hasOrgAccess[0]?.urm_level_id;
40
+ if (hasOrgAccess[0].urm_level_id == 1) {
41
+ currentORGLevel_id = org_id;
42
+ }
43
+
44
+ console.log('currentORGLevel_id', currentORGLevel_id);
45
+
37
46
  if (hasOrgAccess.length > 0) {
38
47
  const schools = await this.dataSource
39
48
  .createQueryBuilder()
@@ -53,9 +62,11 @@ export class SchoolRepository {
53
62
  .from('cr_school', 'sch')
54
63
  .innerJoin('cr_brand', 'br', 'sch.brand_id = br.id')
55
64
  .innerJoin('cr_organization', 'org', 'br.organization_id = org.id')
56
- .where('org.id = :orgId', { orgId: hasOrgAccess[0].urm_level_id })
65
+ .where('org.id = :orgId', { orgId: currentORGLevel_id })
57
66
  .getRawMany();
58
67
 
68
+ console.log('schools', schools);
69
+
59
70
  const result = {};
60
71
  for (const row of schools) {
61
72
  const {
@@ -78,7 +78,15 @@ export class OrganizationService {
78
78
  await repo.delete(id);
79
79
  }
80
80
 
81
- async getOrganizationHierarchy(userId: number, appCode: string) {
82
- return await this.schoolRepository.getUserContextDropdown(userId, appCode);
81
+ async getOrganizationHierarchy(
82
+ userId: number,
83
+ appCode: string,
84
+ orgId: number,
85
+ ) {
86
+ return await this.schoolRepository.getUserContextDropdown(
87
+ userId,
88
+ appCode,
89
+ orgId,
90
+ );
83
91
  }
84
92
  }