rez_core 2.0.65 → 2.0.67
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/dist/module/meta/service/entity-service-impl.service.d.ts +1 -0
- package/dist/module/meta/service/entity-service-impl.service.js +8 -0
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +5 -6
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/service/entity-service-impl.service.ts +17 -0
- package/src/module/module/repository/menu.repository.ts +15 -15
package/package.json
CHANGED
|
@@ -132,6 +132,23 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
132
132
|
return await repoService.findOne({ where: { id: id } });
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
async getEntityDataAll(
|
|
136
|
+
entityType: string,
|
|
137
|
+
type: {},
|
|
138
|
+
): Promise<BaseEntity[] | null> {
|
|
139
|
+
const entityData = await this.entityMasterService.getEntityData(entityType);
|
|
140
|
+
|
|
141
|
+
const repoService = this.reflectionHelper.getRepoService(
|
|
142
|
+
entityData.entity_data_class,
|
|
143
|
+
);
|
|
144
|
+
if (!repoService) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Repository service not found for entityType: ${entityType}`,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return await repoService.find({ where: type });
|
|
150
|
+
}
|
|
151
|
+
|
|
135
152
|
async getEntityList(
|
|
136
153
|
entityType: string,
|
|
137
154
|
filters: Record<string, any> = {},
|
|
@@ -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.
|
|
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
|
|
104
|
-
const orgId = sch?.
|
|
105
|
-
|
|
106
|
-
if (
|
|
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:
|
|
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
|
}
|