rez_core 2.0.65 → 2.0.66

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.65",
3
+ "version": "2.0.66",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -78,7 +78,7 @@ export class MenuRepository extends Repository<MenuData> {
78
78
  levelId: number,
79
79
  ): Promise<number[]> {
80
80
  const repo = this.dataSource.getRepository(UserRoleMapping);
81
-
81
+
82
82
  // 1. Try exact level match
83
83
  let roles = await repo.createQueryBuilder('urm')
84
84
  .innerJoin('cr_role', 'role', 'role.id = urm.role_id')
@@ -88,34 +88,33 @@ export class MenuRepository extends Repository<MenuData> {
88
88
  .andWhere('urm.level_id = :levelId', { levelId })
89
89
  .andWhere('role.appcode = :appcode', { appcode })
90
90
  .getRawMany();
91
-
91
+
92
92
  if (roles.length) return roles.map(r => r.urm_role_id);
93
-
93
+
94
94
  // 2. If SCH fallback → BRN → ORG
95
95
  if (levelType === 'SCH') {
96
96
  const [sch] = await this.dataSource.query(`
97
- SELECT s.brn_id, b.org_id
97
+ SELECT s.brand_id, s.organization_id
98
98
  FROM cr_school s
99
- LEFT JOIN cr_brand b ON s.brn_id = b.id
100
99
  WHERE s.id = $1
101
100
  `, [levelId]);
102
-
103
- const branchId = sch?.brn_id;
104
- const orgId = sch?.org_id;
105
-
106
- if (branchId) {
101
+
102
+ const brandId = sch?.brand_id;
103
+ const orgId = sch?.organization_id;
104
+
105
+ if (brandId) {
107
106
  roles = await repo.createQueryBuilder('urm')
108
107
  .innerJoin('cr_role', 'role', 'role.id = urm.role_id')
109
108
  .select('urm.role_id')
110
109
  .where('urm.user_id = :userId', { userId })
111
110
  .andWhere('urm.level_type = :levelType', { levelType: 'BRN' })
112
- .andWhere('urm.level_id = :levelId', { levelId: branchId })
111
+ .andWhere('urm.level_id = :levelId', { levelId: brandId })
113
112
  .andWhere('role.appcode = :appcode', { appcode })
114
113
  .getRawMany();
115
-
114
+
116
115
  if (roles.length) return roles.map(r => r.urm_role_id);
117
116
  }
118
-
117
+
119
118
  if (orgId) {
120
119
  roles = await repo.createQueryBuilder('urm')
121
120
  .innerJoin('cr_role', 'role', 'role.id = urm.role_id')
@@ -125,11 +124,12 @@ export class MenuRepository extends Repository<MenuData> {
125
124
  .andWhere('urm.level_id = :levelId', { levelId: orgId })
126
125
  .andWhere('role.appcode = :appcode', { appcode })
127
126
  .getRawMany();
128
-
127
+
129
128
  if (roles.length) return roles.map(r => r.urm_role_id);
130
129
  }
131
130
  }
132
-
131
+
133
132
  return [];
134
133
  }
134
+
135
135
  }