rez_core 2.1.6 → 2.1.11
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/dtos/response.d.ts +5 -0
- package/dist/dtos/response.js +3 -0
- package/dist/dtos/response.js.map +1 -0
- package/dist/module/filter/controller/filter.controller.js +1 -0
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/dto/filter-request.dto.d.ts +1 -0
- package/dist/module/filter/service/filter.service.js +8 -2
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/listmaster/controller/list-master.controller.d.ts +1 -1
- package/dist/module/listmaster/controller/list-master.controller.js +12 -4
- package/dist/module/listmaster/controller/list-master.controller.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.d.ts +2 -1
- package/dist/module/listmaster/service/list-master.service.js +53 -13
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/master/service/master.service.d.ts +1 -4
- package/dist/module/master/service/master.service.js +19 -75
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/controller/entity.controller.d.ts +2 -2
- package/dist/module/meta/controller/entity.controller.js +71 -20
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.js +3 -4
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +6 -5
- package/dist/module/module/repository/module-access.repository.js +22 -18
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +8 -8
- package/dist/module/module/service/module-access.service.js +7 -7
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +3 -2
- package/dist/module/user/service/role.service.js +22 -10
- 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/dtos/response.ts +5 -0
- package/src/module/filter/controller/filter.controller.ts +1 -0
- package/src/module/filter/dto/filter-request.dto.ts +1 -0
- package/src/module/filter/service/filter.service.ts +9 -1
- package/src/module/listmaster/controller/list-master.controller.ts +32 -3
- package/src/module/listmaster/service/list-master.service.ts +93 -13
- package/src/module/master/service/master.service.ts +38 -92
- package/src/module/meta/controller/entity.controller.ts +101 -47
- package/src/module/module/controller/module-access.controller.ts +3 -5
- package/src/module/module/repository/module-access.repository.ts +25 -16
- package/src/module/module/service/module-access.service.ts +12 -9
- package/src/module/user/service/role.service.ts +25 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import { In, Not, Repository , IsNull} from 'typeorm';
|
|
3
|
+
import { In, Not, Repository , IsNull, DataSource} 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';
|
|
@@ -21,10 +21,13 @@ export class ModuleAccessRepository {
|
|
|
21
21
|
|
|
22
22
|
@InjectRepository(ModuleAction)
|
|
23
23
|
private readonly moduleActionRepo: Repository<ModuleAction>,
|
|
24
|
+
|
|
25
|
+
private readonly dataSource: DataSource,
|
|
24
26
|
) {}
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
|
|
28
31
|
async getRoles({
|
|
29
32
|
appcode,
|
|
30
33
|
level_type,
|
|
@@ -34,15 +37,23 @@ export class ModuleAccessRepository {
|
|
|
34
37
|
level_type?: string;
|
|
35
38
|
level_id?: number;
|
|
36
39
|
}) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
const query = this.dataSource
|
|
41
|
+
.createQueryBuilder()
|
|
42
|
+
.select('*')
|
|
43
|
+
.from('cr_role', 'role')
|
|
44
|
+
.where('role.appcode = :appcode', { appcode })
|
|
45
|
+
.andWhere('(role.is_factory IS NULL OR role.is_factory != 1)');
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if (level_type) {
|
|
49
|
+
query.andWhere('role.level_type = :level_type', { level_type });
|
|
50
|
+
}
|
|
41
51
|
|
|
42
|
-
if (
|
|
43
|
-
|
|
52
|
+
if (level_id !== undefined) {
|
|
53
|
+
query.andWhere('role.level_id = :level_id', { level_id: String(level_id) });
|
|
54
|
+
}
|
|
44
55
|
|
|
45
|
-
const roles = await
|
|
56
|
+
const roles = await query.getRawMany(); // use getRawMany since you're selecting from a raw table
|
|
46
57
|
|
|
47
58
|
return roles.map((role) => ({
|
|
48
59
|
label: role.name,
|
|
@@ -50,6 +61,7 @@ export class ModuleAccessRepository {
|
|
|
50
61
|
}));
|
|
51
62
|
}
|
|
52
63
|
|
|
64
|
+
|
|
53
65
|
|
|
54
66
|
async getModules({ appcode }: { appcode: string }) {
|
|
55
67
|
const modules = await this.moduleRepo.find({
|
|
@@ -73,7 +85,7 @@ export class ModuleAccessRepository {
|
|
|
73
85
|
) {
|
|
74
86
|
let roles;
|
|
75
87
|
|
|
76
|
-
if (roleIds.length === 1 && roleIds[0] ===
|
|
88
|
+
if (roleIds.length === 1 && roleIds[0] === -1) {
|
|
77
89
|
// Internally call getRoles
|
|
78
90
|
const fetchedRoles = await this.getRoles({
|
|
79
91
|
appcode,
|
|
@@ -118,6 +130,7 @@ export class ModuleAccessRepository {
|
|
|
118
130
|
access: access.access_flag,
|
|
119
131
|
code: access.module_code,
|
|
120
132
|
level_type: access.level_type,
|
|
133
|
+
appcode: access.appcode,
|
|
121
134
|
})),
|
|
122
135
|
}));
|
|
123
136
|
}
|
|
@@ -214,8 +227,7 @@ export class ModuleAccessRepository {
|
|
|
214
227
|
access_flag: number;
|
|
215
228
|
appcode: string;
|
|
216
229
|
level_type: string;
|
|
217
|
-
}[]
|
|
218
|
-
appcode: string,
|
|
230
|
+
}[]
|
|
219
231
|
): Promise<boolean> {
|
|
220
232
|
try {
|
|
221
233
|
for (const access of accessList) {
|
|
@@ -224,7 +236,7 @@ export class ModuleAccessRepository {
|
|
|
224
236
|
role_code: access.role_code,
|
|
225
237
|
module_code: access.module_code,
|
|
226
238
|
action_type: access.action_type,
|
|
227
|
-
appcode: access.appcode
|
|
239
|
+
appcode: access.appcode,
|
|
228
240
|
level_type: access.level_type,
|
|
229
241
|
},
|
|
230
242
|
});
|
|
@@ -234,10 +246,7 @@ export class ModuleAccessRepository {
|
|
|
234
246
|
await this.moduleAccessRepo.save(existing);
|
|
235
247
|
} else {
|
|
236
248
|
await this.moduleAccessRepo.save(
|
|
237
|
-
|
|
238
|
-
...access,
|
|
239
|
-
appcode: access.appcode || appcode,
|
|
240
|
-
}),
|
|
249
|
+
await this.moduleAccessRepo.create(access),
|
|
241
250
|
);
|
|
242
251
|
}
|
|
243
252
|
}
|
|
@@ -15,6 +15,15 @@ export class ModuleAccessService {
|
|
|
15
15
|
private readonly menuRepository: MenuRepository,
|
|
16
16
|
private readonly dataSource: DataSource,
|
|
17
17
|
) {}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
async getModules({ appcode }: { appcode: string }) {
|
|
21
|
+
return this.moduleAccessRepository.getModules({
|
|
22
|
+
appcode,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
18
27
|
async getRoles({
|
|
19
28
|
appcode,
|
|
20
29
|
level_type,
|
|
@@ -48,13 +57,6 @@ export class ModuleAccessService {
|
|
|
48
57
|
}));
|
|
49
58
|
}
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async getModules({ appcode }: { appcode: string }) {
|
|
54
|
-
return this.moduleAccessRepository.getModules({
|
|
55
|
-
appcode,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
60
|
async getAccessListing(
|
|
59
61
|
roleIds: number[],
|
|
60
62
|
appcode: string,
|
|
@@ -94,7 +96,6 @@ export class ModuleAccessService {
|
|
|
94
96
|
appcode: string;
|
|
95
97
|
level_type: string;
|
|
96
98
|
}[],
|
|
97
|
-
appcode: string,
|
|
98
99
|
): Promise<{ success: boolean; msg: string }> {
|
|
99
100
|
if (!moduleAccessData || moduleAccessData.length === 0) {
|
|
100
101
|
return { success: false, msg: 'No data provided' };
|
|
@@ -102,7 +103,6 @@ export class ModuleAccessService {
|
|
|
102
103
|
|
|
103
104
|
const result = await this.moduleAccessRepository.updateModuleAccess(
|
|
104
105
|
moduleAccessData,
|
|
105
|
-
appcode,
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
if (result) {
|
|
@@ -118,3 +118,6 @@ export class ModuleAccessService {
|
|
|
118
118
|
return this.moduleAccessRepository.getModuleUIConfig(moduleCode, roleIds);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
//hi
|
|
@@ -8,6 +8,7 @@ import { RoleRepository } from '../repository/role.repository';
|
|
|
8
8
|
import { EntityManager, Repository } from 'typeorm';
|
|
9
9
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
10
10
|
import { ModuleAccess } from '../../module/entity/module-access.entity';
|
|
11
|
+
import { ServiceResult } from 'src/dtos/response';
|
|
11
12
|
|
|
12
13
|
@Injectable()
|
|
13
14
|
export class RoleService extends EntityServiceImpl {
|
|
@@ -23,7 +24,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
23
24
|
async createEntity(
|
|
24
25
|
entityData: BaseEntity,
|
|
25
26
|
loggedInUser: UserData,
|
|
26
|
-
): Promise<BaseEntity
|
|
27
|
+
): Promise<ServiceResult<BaseEntity>> {
|
|
27
28
|
let role = entityData as Role;
|
|
28
29
|
|
|
29
30
|
// if level_type and level_id are not provided, use loggedInUser's values
|
|
@@ -40,7 +41,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
40
41
|
parseInt(loggedInUser?.level_id || '', 10),
|
|
41
42
|
})
|
|
42
43
|
) {
|
|
43
|
-
|
|
44
|
+
return { success: false, error: 'Role code already exists.' };
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const sourceRole = role.copy_from_role_id
|
|
@@ -48,7 +49,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
48
49
|
: null;
|
|
49
50
|
|
|
50
51
|
if (role.copy_from_role_id && !sourceRole) {
|
|
51
|
-
|
|
52
|
+
return { success: false, error: 'Source role not found.' };
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const savedRole = await super.createEntity(role, loggedInUser);
|
|
@@ -70,15 +71,15 @@ export class RoleService extends EntityServiceImpl {
|
|
|
70
71
|
|
|
71
72
|
await this.moduleAccessRepo.save(clonedPermissions);
|
|
72
73
|
}
|
|
73
|
-
return savedRole;
|
|
74
|
+
return { success: true, data: savedRole };
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
async updateEntity(
|
|
77
78
|
entityData: BaseEntity,
|
|
78
79
|
loggedInUser: UserData | null,
|
|
79
|
-
): Promise<BaseEntity
|
|
80
|
+
): Promise<ServiceResult<BaseEntity>> {
|
|
80
81
|
if (!entityData.name) {
|
|
81
|
-
|
|
82
|
+
return { success: false, error: 'Role name is required' };
|
|
82
83
|
}
|
|
83
84
|
const role = entityData as Role;
|
|
84
85
|
|
|
@@ -90,7 +91,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
90
91
|
);
|
|
91
92
|
|
|
92
93
|
if (!existingRole) {
|
|
93
|
-
|
|
94
|
+
return { success: false, error: 'Role not found' };
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
const associatedUsers = await this.entityManager.query(`SELECT map.*
|
|
@@ -100,13 +101,17 @@ export class RoleService extends EntityServiceImpl {
|
|
|
100
101
|
and map.role_id = ${existingRole?.id}`);
|
|
101
102
|
|
|
102
103
|
if (associatedUsers.length > 0) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
error: 'Cannot deactivate role as it is associated with active users',
|
|
107
|
+
};
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
if (role.is_system === 1) {
|
|
109
|
-
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
error: 'Cannot deactivate system role',
|
|
114
|
+
};
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
|
|
@@ -116,7 +121,10 @@ export class RoleService extends EntityServiceImpl {
|
|
|
116
121
|
organization_id: loggedInUser?.organization_id,
|
|
117
122
|
})
|
|
118
123
|
) {
|
|
119
|
-
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
error: 'Role name already exists.',
|
|
127
|
+
};
|
|
120
128
|
}
|
|
121
129
|
|
|
122
130
|
const { copy_from_role_id, ...persistableData } = role;
|
|
@@ -129,7 +137,10 @@ export class RoleService extends EntityServiceImpl {
|
|
|
129
137
|
);
|
|
130
138
|
|
|
131
139
|
if (!sourceRole) {
|
|
132
|
-
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
error: 'Source role not found',
|
|
143
|
+
};
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
await this.moduleAccessRepo.delete({ role_code: role.code });
|
|
@@ -151,7 +162,7 @@ export class RoleService extends EntityServiceImpl {
|
|
|
151
162
|
|
|
152
163
|
await this.moduleAccessRepo.save(clonedPermissions);
|
|
153
164
|
}
|
|
154
|
-
return updatedRole;
|
|
165
|
+
return { success: true, data: updatedRole };
|
|
155
166
|
}
|
|
156
167
|
|
|
157
168
|
async getDefaultRole(data: {
|