rez_core 2.0.44 → 2.0.46
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/enterprise/controller/organization.controller.js +0 -1
- package/dist/module/enterprise/controller/organization.controller.js.map +1 -1
- package/dist/module/enterprise/entity/school.entity.d.ts +1 -0
- package/dist/module/enterprise/entity/school.entity.js +4 -0
- package/dist/module/enterprise/entity/school.entity.js.map +1 -1
- package/dist/module/enterprise/repository/school.repository.js +12 -4
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/meta/entity/app-master.entity.d.ts +1 -0
- package/dist/module/meta/entity/app-master.entity.js +4 -0
- package/dist/module/meta/entity/app-master.entity.js.map +1 -1
- package/dist/module/meta/service/app-master.service.d.ts +1 -1
- package/dist/module/meta/service/app-master.service.js +8 -5
- package/dist/module/meta/service/app-master.service.js.map +1 -1
- package/dist/module/user/repository/role.repository.d.ts +1 -0
- package/dist/module/user/repository/role.repository.js +12 -1
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +6 -0
- package/dist/module/user/service/role.service.js +10 -2
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/enterprise/controller/organization.controller.ts +0 -2
- package/src/module/enterprise/entity/school.entity.ts +3 -0
- package/src/module/enterprise/repository/school.repository.ts +19 -3
- package/src/module/meta/entity/app-master.entity.ts +3 -0
- package/src/module/meta/service/app-master.service.ts +8 -5
- package/src/module/user/repository/role.repository.ts +18 -8
- package/src/module/user/service/role.service.ts +21 -6
package/package.json
CHANGED
|
@@ -27,8 +27,6 @@ export class OrganizationController {
|
|
|
27
27
|
const userId = req.user.userData?.id;
|
|
28
28
|
const appcode = req.user.userData?.appcode;
|
|
29
29
|
|
|
30
|
-
console.log(userId, appcode, 'userId, appcode');
|
|
31
|
-
|
|
32
30
|
return await this.orgService.getOrganizationHierarchy(userId, appcode);
|
|
33
31
|
}
|
|
34
32
|
}
|
|
@@ -35,7 +35,6 @@ export class SchoolRepository {
|
|
|
35
35
|
.andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
|
|
36
36
|
.getRawMany();
|
|
37
37
|
|
|
38
|
-
console.log(hasOrgAccess);
|
|
39
38
|
if (hasOrgAccess.length > 0) {
|
|
40
39
|
// Return nested Org -> Brand -> School structure
|
|
41
40
|
const schools = await this.dataSource
|
|
@@ -43,10 +42,12 @@ export class SchoolRepository {
|
|
|
43
42
|
.select([
|
|
44
43
|
'org.id AS org_id',
|
|
45
44
|
'org.name AS org_name',
|
|
45
|
+
'org.address AS org_address',
|
|
46
46
|
'br.id AS brand_id',
|
|
47
47
|
'br.name AS brand_name',
|
|
48
48
|
'sch.id AS school_id',
|
|
49
49
|
'sch.name AS school_name',
|
|
50
|
+
'sch.location AS school_location',
|
|
50
51
|
])
|
|
51
52
|
.from('cr_school', 'sch')
|
|
52
53
|
.innerJoin('cr_brand', 'br', 'sch.brand_id = br.id')
|
|
@@ -59,16 +60,19 @@ export class SchoolRepository {
|
|
|
59
60
|
const {
|
|
60
61
|
org_id,
|
|
61
62
|
org_name,
|
|
63
|
+
org_address,
|
|
62
64
|
brand_id,
|
|
63
65
|
brand_name,
|
|
64
66
|
school_id,
|
|
65
67
|
school_name,
|
|
68
|
+
school_location,
|
|
66
69
|
} = row;
|
|
67
70
|
|
|
68
71
|
if (!result[org_id]) {
|
|
69
72
|
result[org_id] = {
|
|
70
73
|
org_id,
|
|
71
74
|
org_name,
|
|
75
|
+
org_address,
|
|
72
76
|
brands: {},
|
|
73
77
|
};
|
|
74
78
|
}
|
|
@@ -82,6 +86,7 @@ export class SchoolRepository {
|
|
|
82
86
|
result[org_id].brands[brand_id].schools.push({
|
|
83
87
|
school_id,
|
|
84
88
|
school_name,
|
|
89
|
+
school_location,
|
|
85
90
|
});
|
|
86
91
|
}
|
|
87
92
|
|
|
@@ -98,6 +103,7 @@ export class SchoolRepository {
|
|
|
98
103
|
'brand.name AS brand_name',
|
|
99
104
|
'school.id AS school_id',
|
|
100
105
|
'school.name AS school_name',
|
|
106
|
+
'school.location AS school_location',
|
|
101
107
|
])
|
|
102
108
|
.from('cr_user_role_mapping', 'urm')
|
|
103
109
|
.innerJoin('cr_brand', 'brand', 'brand.id = urm.level_id')
|
|
@@ -130,7 +136,13 @@ export class SchoolRepository {
|
|
|
130
136
|
// 4. Group by brand
|
|
131
137
|
const result = {};
|
|
132
138
|
for (const row of allMappings) {
|
|
133
|
-
const {
|
|
139
|
+
const {
|
|
140
|
+
brand_id,
|
|
141
|
+
brand_name,
|
|
142
|
+
school_id,
|
|
143
|
+
school_name,
|
|
144
|
+
school_location,
|
|
145
|
+
} = row;
|
|
134
146
|
|
|
135
147
|
if (!result[brand_id]) {
|
|
136
148
|
result[brand_id] = {
|
|
@@ -145,7 +157,11 @@ export class SchoolRepository {
|
|
|
145
157
|
school_id &&
|
|
146
158
|
!result[brand_id].schools.some((s) => s.school_id === school_id)
|
|
147
159
|
) {
|
|
148
|
-
result[brand_id].schools.push({
|
|
160
|
+
result[brand_id].schools.push({
|
|
161
|
+
school_id,
|
|
162
|
+
school_name,
|
|
163
|
+
school_location,
|
|
164
|
+
});
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
|
|
@@ -13,22 +13,25 @@ export class AppMasterService {
|
|
|
13
13
|
const app_code =
|
|
14
14
|
await this.userRoleMappingRepository.findDistinctAppcodeByUserId(userId);
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const finalResult: any[] = [];
|
|
17
17
|
|
|
18
18
|
if (app_code.appcode.length > 0) {
|
|
19
19
|
const resolvedData = await Promise.all(
|
|
20
20
|
app_code.appcode.map(async (element) => {
|
|
21
21
|
const data =
|
|
22
22
|
await this.appMasterRepository.getAppMasterDataByAppCode(element);
|
|
23
|
-
return
|
|
23
|
+
return data || [];
|
|
24
24
|
}),
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
resolvedData.forEach((
|
|
28
|
-
|
|
27
|
+
resolvedData.flat().forEach((item) => {
|
|
28
|
+
finalResult.push({
|
|
29
|
+
key: item.name,
|
|
30
|
+
details: item,
|
|
31
|
+
});
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
return
|
|
35
|
+
return finalResult;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -9,34 +9,44 @@ import { UserData } from '../entity/user.entity';
|
|
|
9
9
|
export class RoleRepository {
|
|
10
10
|
constructor(
|
|
11
11
|
@InjectRepository(Role)
|
|
12
|
-
private readonly roleRepo: Repository<Role
|
|
12
|
+
private readonly roleRepo: Repository<Role>,
|
|
13
13
|
) {}
|
|
14
14
|
|
|
15
15
|
async findByCode(code: string): Promise<Role | null> {
|
|
16
16
|
return this.roleRepo.findOne({ where: { code } });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
19
|
public async isRoleNameExists(
|
|
21
20
|
name: string,
|
|
22
|
-
options?: { excludeRoleId?: number; organization_id?: number }
|
|
21
|
+
options?: { excludeRoleId?: number; organization_id?: number },
|
|
23
22
|
): Promise<boolean> {
|
|
24
23
|
const query = this.roleRepo
|
|
25
24
|
.createQueryBuilder('role')
|
|
26
25
|
.where('role.name = :name', { name });
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
if (options?.excludeRoleId) {
|
|
29
|
-
query.andWhere('role.id != :excludeRoleId', {
|
|
28
|
+
query.andWhere('role.id != :excludeRoleId', {
|
|
29
|
+
excludeRoleId: options.excludeRoleId,
|
|
30
|
+
});
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
+
|
|
32
33
|
if (options?.organization_id !== undefined) {
|
|
33
34
|
query.andWhere('role.organization_id = :organization_id', {
|
|
34
35
|
organization_id: options.organization_id,
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
const existingRole = await query.getOne();
|
|
39
40
|
return !!existingRole;
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
|
|
43
|
+
async find(data): Promise<Role[] | null> {
|
|
44
|
+
return this.roleRepo.find({
|
|
45
|
+
where: {
|
|
46
|
+
...(data.is_factory !== undefined && { is_factory: data.is_factory }),
|
|
47
|
+
...(data.level_id !== undefined && { level_id: data.level_id }),
|
|
48
|
+
...(data.level_type !== undefined && { level_type: data.level_type }),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
42
52
|
}
|
|
@@ -28,10 +28,14 @@ export class RoleService extends EntityServiceImpl {
|
|
|
28
28
|
appcode?: string,
|
|
29
29
|
): Promise<BaseEntity> {
|
|
30
30
|
let role = entityData as Role;
|
|
31
|
-
if(appcode){
|
|
32
|
-
role.appcode = appcode
|
|
31
|
+
if (appcode) {
|
|
32
|
+
role.appcode = appcode;
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
34
|
+
if (
|
|
35
|
+
await this.roleRepository.isRoleNameExists(role.name, {
|
|
36
|
+
organization_id: entityData.organization_id,
|
|
37
|
+
})
|
|
38
|
+
) {
|
|
35
39
|
throw new BadRequestException('Role name already exists.');
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -102,13 +106,16 @@ export class RoleService extends EntityServiceImpl {
|
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
if (
|
|
105
|
-
await this.roleRepository.isRoleNameExists(entityData.name, {
|
|
109
|
+
await this.roleRepository.isRoleNameExists(entityData.name, {
|
|
110
|
+
excludeRoleId: entityData.id,
|
|
111
|
+
organization_id: loggedInUser?.organization_id,
|
|
112
|
+
})
|
|
106
113
|
) {
|
|
107
114
|
throw new BadRequestException('Role name already exists.');
|
|
108
115
|
}
|
|
109
116
|
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
const { copy_from_role_id, ...persistableData } = role;
|
|
118
|
+
const updatedRole = await super.updateEntity(persistableData, loggedInUser);
|
|
112
119
|
|
|
113
120
|
if (role.copy_from_role_id) {
|
|
114
121
|
const sourceRole = await this.getEntityData(
|
|
@@ -140,4 +147,12 @@ export class RoleService extends EntityServiceImpl {
|
|
|
140
147
|
}
|
|
141
148
|
return updatedRole;
|
|
142
149
|
}
|
|
150
|
+
|
|
151
|
+
async getDefaultRole(data: {
|
|
152
|
+
is_factory?: boolean;
|
|
153
|
+
level_id?: number;
|
|
154
|
+
level_type?: string;
|
|
155
|
+
}): Promise<Role[] | null> {
|
|
156
|
+
return await this.roleRepository.find(data);
|
|
157
|
+
}
|
|
143
158
|
}
|