rez_core 1.0.60 → 1.0.62
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/entity/enterprise.entity.d.ts +7 -7
- package/dist/module/enterprise/entity/enterprise.entity.js +7 -7
- package/dist/module/enterprise/entity/enterprise.entity.js.map +1 -1
- package/dist/module/enterprise/repository/enterprise.repository.d.ts +8 -0
- package/dist/module/enterprise/repository/enterprise.repository.js +48 -0
- package/dist/module/enterprise/repository/enterprise.repository.js.map +1 -0
- package/dist/module/enterprise/service/enterprise.service.d.ts +8 -0
- package/dist/module/enterprise/service/enterprise.service.js +31 -0
- package/dist/module/enterprise/service/enterprise.service.js.map +1 -0
- package/dist/module/meta/controller/view-master.controller.d.ts +7 -0
- package/dist/module/meta/controller/view-master.controller.js +62 -0
- package/dist/module/meta/controller/view-master.controller.js.map +1 -0
- package/dist/module/meta/entity/view-master.entity.d.ts +2 -0
- package/dist/module/meta/entity/view-master.entity.js +8 -0
- package/dist/module/meta/entity/view-master.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +4 -1
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/view-master.repository.d.ts +7 -0
- package/dist/module/meta/repository/view-master.repository.js +38 -0
- package/dist/module/meta/repository/view-master.repository.js.map +1 -0
- package/dist/module/meta/service/entity-list.service.d.ts +1 -1
- package/dist/module/meta/service/entity-list.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.d.ts +1 -1
- package/dist/module/meta/service/entity-master.service.js +11 -6
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/view-master.service.d.ts +13 -2
- package/dist/module/meta/service/view-master.service.js +41 -22
- package/dist/module/meta/service/view-master.service.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +1 -37
- package/dist/module/module/controller/module-access.controller.js +2 -34
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +1 -35
- package/dist/module/module/repository/module-access.repository.js +2 -104
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +1 -36
- package/dist/module/module/service/module-access.service.js +2 -44
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/user/controller/role.controller.d.ts +41 -0
- package/dist/module/user/controller/role.controller.js +63 -0
- package/dist/module/user/controller/role.controller.js.map +1 -0
- package/dist/module/user/repository/role.repository.d.ts +35 -1
- package/dist/module/user/repository/role.repository.js +105 -2
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +35 -1
- package/dist/module/user/service/role.service.js +39 -2
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +2 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +4 -2
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/enterprise/entity/enterprise.entity.ts +7 -7
- package/src/module/enterprise/repository/enterprise.repository.ts +31 -0
- package/src/module/enterprise/service/enterprise.service.ts +16 -0
- package/src/module/meta/controller/view-master.controller.ts +48 -0
- package/src/module/meta/entity/view-master.entity.ts +6 -0
- package/src/module/meta/entity.module.ts +4 -1
- package/src/module/meta/repository/view-master.repository.ts +24 -0
- package/src/module/meta/service/entity-list.service.ts +2 -2
- package/src/module/meta/service/entity-master.service.ts +15 -11
- package/src/module/meta/service/view-master.service.ts +51 -28
- package/src/module/module/controller/module-access.controller.ts +2 -36
- package/src/module/module/repository/module-access.repository.ts +0 -151
- package/src/module/module/service/module-access.service.ts +1 -62
- package/src/module/user/controller/role.controller.ts +55 -0
- package/src/module/user/repository/role.repository.ts +157 -1
- package/src/module/user/service/role.service.ts +70 -2
- package/src/module/user/service/user.service.ts +6 -3
- package/src/module/user/user.module.ts +4 -2
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ModuleAccessService } from '../service/module-access.service';
|
|
2
|
-
import { UserService } from '../../user/service/user.service';
|
|
3
2
|
export declare class ModuleAccessController {
|
|
4
3
|
private readonly moduleAccessService;
|
|
5
|
-
|
|
6
|
-
constructor(moduleAccessService: ModuleAccessService, userService: UserService);
|
|
4
|
+
constructor(moduleAccessService: ModuleAccessService);
|
|
7
5
|
getRoles(): Promise<{
|
|
8
6
|
label: string;
|
|
9
7
|
value: number;
|
|
@@ -34,38 +32,4 @@ export declare class ModuleAccessController {
|
|
|
34
32
|
success: boolean;
|
|
35
33
|
msg: string;
|
|
36
34
|
}>;
|
|
37
|
-
createRole(body: {
|
|
38
|
-
name: string;
|
|
39
|
-
description?: string;
|
|
40
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
41
|
-
copyFromRoleId?: number;
|
|
42
|
-
}, req: Request & {
|
|
43
|
-
user: any;
|
|
44
|
-
}): Promise<{
|
|
45
|
-
success: boolean;
|
|
46
|
-
msg: string;
|
|
47
|
-
role: {
|
|
48
|
-
id: number;
|
|
49
|
-
name: string;
|
|
50
|
-
status: string;
|
|
51
|
-
code: string;
|
|
52
|
-
};
|
|
53
|
-
}>;
|
|
54
|
-
updateRole(id: number, body: {
|
|
55
|
-
name?: string;
|
|
56
|
-
description?: string;
|
|
57
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
58
|
-
copyFromRoleId?: number;
|
|
59
|
-
}, req: Request & {
|
|
60
|
-
user: any;
|
|
61
|
-
}): Promise<{
|
|
62
|
-
success: boolean;
|
|
63
|
-
msg: string;
|
|
64
|
-
role: {
|
|
65
|
-
id: number;
|
|
66
|
-
name: string;
|
|
67
|
-
status: string;
|
|
68
|
-
code: string;
|
|
69
|
-
};
|
|
70
|
-
}>;
|
|
71
35
|
}
|
|
@@ -16,12 +16,9 @@ exports.ModuleAccessController = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const module_access_service_1 = require("../service/module-access.service");
|
|
18
18
|
const jwt_guard_1 = require("../../auth/guards/jwt.guard");
|
|
19
|
-
const global_constant_1 = require("../../../constant/global.constant");
|
|
20
|
-
const user_service_1 = require("../../user/service/user.service");
|
|
21
19
|
let ModuleAccessController = class ModuleAccessController {
|
|
22
|
-
constructor(moduleAccessService
|
|
20
|
+
constructor(moduleAccessService) {
|
|
23
21
|
this.moduleAccessService = moduleAccessService;
|
|
24
|
-
this.userService = userService;
|
|
25
22
|
}
|
|
26
23
|
async getRoles() {
|
|
27
24
|
return this.moduleAccessService.getRoles();
|
|
@@ -40,16 +37,6 @@ let ModuleAccessController = class ModuleAccessController {
|
|
|
40
37
|
async updateModuleAccess(moduleAccessData) {
|
|
41
38
|
return this.moduleAccessService.updateModuleAccess(moduleAccessData);
|
|
42
39
|
}
|
|
43
|
-
async createRole(body, req) {
|
|
44
|
-
let requestedUser = req.user;
|
|
45
|
-
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
46
|
-
return this.moduleAccessService.createRole(body, loggedInUser);
|
|
47
|
-
}
|
|
48
|
-
async updateRole(id, body, req) {
|
|
49
|
-
let requestedUser = req.user;
|
|
50
|
-
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
51
|
-
return this.moduleAccessService.updateRole(id, body, loggedInUser);
|
|
52
|
-
}
|
|
53
40
|
};
|
|
54
41
|
exports.ModuleAccessController = ModuleAccessController;
|
|
55
42
|
__decorate([
|
|
@@ -85,28 +72,9 @@ __decorate([
|
|
|
85
72
|
__metadata("design:paramtypes", [Array]),
|
|
86
73
|
__metadata("design:returntype", Promise)
|
|
87
74
|
], ModuleAccessController.prototype, "updateModuleAccess", null);
|
|
88
|
-
__decorate([
|
|
89
|
-
(0, common_1.Post)('create-role'),
|
|
90
|
-
__param(0, (0, common_1.Body)()),
|
|
91
|
-
__param(1, (0, common_1.Req)()),
|
|
92
|
-
__metadata("design:type", Function),
|
|
93
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
94
|
-
__metadata("design:returntype", Promise)
|
|
95
|
-
], ModuleAccessController.prototype, "createRole", null);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, common_1.Post)('update-role/:id'),
|
|
98
|
-
__param(0, (0, common_1.Param)('id')),
|
|
99
|
-
__param(1, (0, common_1.Body)()),
|
|
100
|
-
__param(2, (0, common_1.Req)()),
|
|
101
|
-
__metadata("design:type", Function),
|
|
102
|
-
__metadata("design:paramtypes", [Number, Object, Object]),
|
|
103
|
-
__metadata("design:returntype", Promise)
|
|
104
|
-
], ModuleAccessController.prototype, "updateRole", null);
|
|
105
75
|
exports.ModuleAccessController = ModuleAccessController = __decorate([
|
|
106
76
|
(0, common_1.Controller)('module-access'),
|
|
107
77
|
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
108
|
-
|
|
109
|
-
__metadata("design:paramtypes", [module_access_service_1.ModuleAccessService,
|
|
110
|
-
user_service_1.UserService])
|
|
78
|
+
__metadata("design:paramtypes", [module_access_service_1.ModuleAccessService])
|
|
111
79
|
], ModuleAccessController);
|
|
112
80
|
//# sourceMappingURL=module-access.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-access.controller.js","sourceRoot":"","sources":["../../../../src/module/module/controller/module-access.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmG;AACnG,4EAAuE;AACvE,2DAAgE;
|
|
1
|
+
{"version":3,"file":"module-access.controller.js","sourceRoot":"","sources":["../../../../src/module/module/controller/module-access.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmG;AACnG,4EAAuE;AACvE,2DAAgE;AAOzD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,mBAAwC;QAAxC,wBAAmB,GAAnB,mBAAmB,CAAqB;IAAG,CAAC;IAGnE,AAAN,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAA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AmB;GAD1D,sBAAsB,CAiClC"}
|
|
@@ -3,15 +3,12 @@ import { Role } from 'src/module/user/entity/role.entity';
|
|
|
3
3
|
import { ModuleAccess } from '../entity/module-access.entity';
|
|
4
4
|
import { ModuleAction } from '../entity/module-action.entity';
|
|
5
5
|
import { ModuleData } from '../entity/module.entity';
|
|
6
|
-
import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
|
|
7
|
-
import { UserData } from 'src/module/user/entity/user.entity';
|
|
8
6
|
export declare class ModuleAccessRepository {
|
|
9
7
|
private readonly roleRepo;
|
|
10
8
|
private readonly moduleRepo;
|
|
11
9
|
private readonly moduleAccessRepo;
|
|
12
10
|
private readonly moduleActionRepo;
|
|
13
|
-
|
|
14
|
-
constructor(roleRepo: Repository<Role>, moduleRepo: Repository<ModuleData>, moduleAccessRepo: Repository<ModuleAccess>, moduleActionRepo: Repository<ModuleAction>, clockIDGenService: ClockIDGenService);
|
|
11
|
+
constructor(roleRepo: Repository<Role>, moduleRepo: Repository<ModuleData>, moduleAccessRepo: Repository<ModuleAccess>, moduleActionRepo: Repository<ModuleAction>);
|
|
15
12
|
getRoles(): Promise<{
|
|
16
13
|
label: string;
|
|
17
14
|
value: number;
|
|
@@ -45,35 +42,4 @@ export declare class ModuleAccessRepository {
|
|
|
45
42
|
access_flag: number;
|
|
46
43
|
app_code: string;
|
|
47
44
|
}[]): Promise<boolean>;
|
|
48
|
-
createRole({ name, description, status, copyFromRoleId, }: {
|
|
49
|
-
name: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
52
|
-
copyFromRoleId?: number;
|
|
53
|
-
}, loggedInUser: UserData): Promise<{
|
|
54
|
-
success: boolean;
|
|
55
|
-
msg: string;
|
|
56
|
-
role: {
|
|
57
|
-
id: number;
|
|
58
|
-
name: string;
|
|
59
|
-
status: string;
|
|
60
|
-
code: string;
|
|
61
|
-
};
|
|
62
|
-
}>;
|
|
63
|
-
updateRole(roleId: number, { name, description, status, copyFromRoleId, }: {
|
|
64
|
-
name: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
67
|
-
copyFromRoleId?: number;
|
|
68
|
-
}, loggedInUser: UserData): Promise<{
|
|
69
|
-
success: boolean;
|
|
70
|
-
msg: string;
|
|
71
|
-
role: {
|
|
72
|
-
id: number;
|
|
73
|
-
name: string;
|
|
74
|
-
status: string;
|
|
75
|
-
code: string;
|
|
76
|
-
};
|
|
77
|
-
}>;
|
|
78
|
-
private isRoleNameExists;
|
|
79
45
|
}
|
|
@@ -20,14 +20,12 @@ const role_entity_1 = require("../../user/entity/role.entity");
|
|
|
20
20
|
const module_access_entity_1 = require("../entity/module-access.entity");
|
|
21
21
|
const module_action_entity_1 = require("../entity/module-action.entity");
|
|
22
22
|
const module_entity_1 = require("../entity/module.entity");
|
|
23
|
-
const clockIDGenUtil_service_1 = require("../../../utils/service/clockIDGenUtil.service");
|
|
24
23
|
let ModuleAccessRepository = class ModuleAccessRepository {
|
|
25
|
-
constructor(roleRepo, moduleRepo, moduleAccessRepo, moduleActionRepo
|
|
24
|
+
constructor(roleRepo, moduleRepo, moduleAccessRepo, moduleActionRepo) {
|
|
26
25
|
this.roleRepo = roleRepo;
|
|
27
26
|
this.moduleRepo = moduleRepo;
|
|
28
27
|
this.moduleAccessRepo = moduleAccessRepo;
|
|
29
28
|
this.moduleActionRepo = moduleActionRepo;
|
|
30
|
-
this.clockIDGenService = clockIDGenService;
|
|
31
29
|
}
|
|
32
30
|
async getRoles() {
|
|
33
31
|
const roles = await this.roleRepo.find();
|
|
@@ -125,105 +123,6 @@ let ModuleAccessRepository = class ModuleAccessRepository {
|
|
|
125
123
|
return false;
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
|
-
async createRole({ name, description, status = 'ACTIVE', copyFromRoleId, }, loggedInUser) {
|
|
129
|
-
if (await this.isRoleNameExists(name)) {
|
|
130
|
-
throw new common_1.BadRequestException('Role name already exists.');
|
|
131
|
-
}
|
|
132
|
-
const sourceRole = copyFromRoleId
|
|
133
|
-
? await this.roleRepo.findOne({ where: { id: copyFromRoleId } })
|
|
134
|
-
: null;
|
|
135
|
-
if (copyFromRoleId && !sourceRole) {
|
|
136
|
-
throw new common_1.BadRequestException('Source role not found.');
|
|
137
|
-
}
|
|
138
|
-
const newRole = this.roleRepo.create({
|
|
139
|
-
name,
|
|
140
|
-
description,
|
|
141
|
-
status,
|
|
142
|
-
created_by: loggedInUser.id,
|
|
143
|
-
created_date: new Date(),
|
|
144
|
-
});
|
|
145
|
-
const savedRole = await this.roleRepo.save(newRole);
|
|
146
|
-
savedRole.code = `ROL${savedRole.id}`;
|
|
147
|
-
await this.roleRepo.save(savedRole);
|
|
148
|
-
if (sourceRole) {
|
|
149
|
-
const sourcePermissions = await this.moduleAccessRepo.find({
|
|
150
|
-
where: { role_code: sourceRole.code },
|
|
151
|
-
});
|
|
152
|
-
const clonedPermissions = sourcePermissions.map(perm => this.moduleAccessRepo.create({
|
|
153
|
-
role_code: savedRole.code,
|
|
154
|
-
module_code: perm.module_code,
|
|
155
|
-
action_type: perm.action_type,
|
|
156
|
-
access_flag: perm.access_flag,
|
|
157
|
-
app_code: perm.app_code,
|
|
158
|
-
}));
|
|
159
|
-
await this.moduleAccessRepo.save(clonedPermissions);
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
success: true,
|
|
163
|
-
msg: 'Role created successfully',
|
|
164
|
-
role: {
|
|
165
|
-
id: savedRole.id,
|
|
166
|
-
name: savedRole.name,
|
|
167
|
-
status: savedRole.status,
|
|
168
|
-
code: savedRole.code,
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async updateRole(roleId, { name, description, status = 'ACTIVE', copyFromRoleId, }, loggedInUser) {
|
|
173
|
-
if (await this.isRoleNameExists(name, roleId)) {
|
|
174
|
-
throw new common_1.BadRequestException('Role name already exists.');
|
|
175
|
-
}
|
|
176
|
-
const role = await this.roleRepo.findOne({ where: { id: roleId } });
|
|
177
|
-
if (!role) {
|
|
178
|
-
throw new common_1.BadRequestException('Role not found');
|
|
179
|
-
}
|
|
180
|
-
Object.assign(role, {
|
|
181
|
-
name,
|
|
182
|
-
description: description || '',
|
|
183
|
-
status,
|
|
184
|
-
modified_by: loggedInUser.id,
|
|
185
|
-
modified_date: new Date(),
|
|
186
|
-
});
|
|
187
|
-
await this.roleRepo.save(role);
|
|
188
|
-
if (copyFromRoleId) {
|
|
189
|
-
const sourceRole = await this.roleRepo.findOne({ where: { id: copyFromRoleId } });
|
|
190
|
-
if (!sourceRole) {
|
|
191
|
-
throw new common_1.BadRequestException('Source role not found');
|
|
192
|
-
}
|
|
193
|
-
await this.moduleAccessRepo.delete({ role_code: role.code });
|
|
194
|
-
const sourcePermissions = await this.moduleAccessRepo.find({
|
|
195
|
-
where: { role_code: sourceRole.code },
|
|
196
|
-
});
|
|
197
|
-
const clonedPermissions = sourcePermissions.map(perm => this.moduleAccessRepo.create({
|
|
198
|
-
role_code: role.code,
|
|
199
|
-
module_code: perm.module_code,
|
|
200
|
-
action_type: perm.action_type,
|
|
201
|
-
access_flag: perm.access_flag,
|
|
202
|
-
app_code: perm.app_code,
|
|
203
|
-
}));
|
|
204
|
-
await this.moduleAccessRepo.save(clonedPermissions);
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
success: true,
|
|
208
|
-
msg: 'Role updated successfully',
|
|
209
|
-
role: {
|
|
210
|
-
id: role.id,
|
|
211
|
-
name: role.name,
|
|
212
|
-
status: role.status,
|
|
213
|
-
code: role.code,
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
async isRoleNameExists(name, excludeRoleId) {
|
|
218
|
-
const query = this.roleRepo
|
|
219
|
-
.createQueryBuilder('role')
|
|
220
|
-
.where('role.name = :name', { name });
|
|
221
|
-
if (excludeRoleId) {
|
|
222
|
-
query.andWhere('role.id != :excludeRoleId', { excludeRoleId });
|
|
223
|
-
}
|
|
224
|
-
const existingRole = await query.getOne();
|
|
225
|
-
return !!existingRole;
|
|
226
|
-
}
|
|
227
126
|
};
|
|
228
127
|
exports.ModuleAccessRepository = ModuleAccessRepository;
|
|
229
128
|
exports.ModuleAccessRepository = ModuleAccessRepository = __decorate([
|
|
@@ -235,7 +134,6 @@ exports.ModuleAccessRepository = ModuleAccessRepository = __decorate([
|
|
|
235
134
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
236
135
|
typeorm_2.Repository,
|
|
237
136
|
typeorm_2.Repository,
|
|
238
|
-
typeorm_2.Repository
|
|
239
|
-
clockIDGenUtil_service_1.ClockIDGenService])
|
|
137
|
+
typeorm_2.Repository])
|
|
240
138
|
], ModuleAccessRepository);
|
|
241
139
|
//# sourceMappingURL=module-access.repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-access.repository.js","sourceRoot":"","sources":["../../../../src/module/module/repository/module-access.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,6CAAmD;AACnD,qCAAyC;AACzC,+DAA0D;AAC1D,yEAA8D;AAC9D,yEAA8D;AAC9D,2DAAqD;
|
|
1
|
+
{"version":3,"file":"module-access.repository.js","sourceRoot":"","sources":["../../../../src/module/module/repository/module-access.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,6CAAmD;AACnD,qCAAyC;AACzC,+DAA0D;AAC1D,yEAA8D;AAC9D,yEAA8D;AAC9D,2DAAqD;AAK9C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAEmB,QAA0B,EAE1B,UAAkC,EAElC,gBAA0C,EAE1C,gBAA0C;QAN1C,aAAQ,GAAR,QAAQ,CAAkB;QAE1B,eAAU,GAAV,UAAU,CAAwB;QAElC,qBAAgB,GAAhB,gBAAgB,CAA0B;QAE1C,qBAAgB,GAAhB,gBAAgB,CAA0B;IAC1D,CAAC;IAEJ,KAAK,CAAC,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AY,CAAC,CAAA;qCALJ,oBAAU;QAER,oBAAU;QAEJ,oBAAU;QAEV,oBAAU;GATpC,sBAAsB,CAoIlC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { ModuleAccessRepository } from '../repository/module-access.repository';
|
|
2
|
-
import { RoleService } from '../../user/service/role.service';
|
|
3
|
-
import { EntityManager } from 'typeorm';
|
|
4
|
-
import { UserData } from 'src/module/user/entity/user.entity';
|
|
5
2
|
export declare class ModuleAccessService {
|
|
6
3
|
private readonly moduleAccessRepository;
|
|
7
|
-
|
|
8
|
-
private readonly entityManager;
|
|
9
|
-
constructor(moduleAccessRepository: ModuleAccessRepository, roleService: RoleService, entityManager: EntityManager);
|
|
4
|
+
constructor(moduleAccessRepository: ModuleAccessRepository);
|
|
10
5
|
getRoles(): Promise<{
|
|
11
6
|
label: string;
|
|
12
7
|
value: number;
|
|
@@ -37,34 +32,4 @@ export declare class ModuleAccessService {
|
|
|
37
32
|
success: boolean;
|
|
38
33
|
msg: string;
|
|
39
34
|
}>;
|
|
40
|
-
createRole(body: {
|
|
41
|
-
name: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
44
|
-
copyFromRoleId?: number;
|
|
45
|
-
}, loggedInUser: UserData): Promise<{
|
|
46
|
-
success: boolean;
|
|
47
|
-
msg: string;
|
|
48
|
-
role: {
|
|
49
|
-
id: number;
|
|
50
|
-
name: string;
|
|
51
|
-
status: string;
|
|
52
|
-
code: string;
|
|
53
|
-
};
|
|
54
|
-
}>;
|
|
55
|
-
updateRole(id: number, body: {
|
|
56
|
-
name?: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
status?: 'ACTIVE' | 'INACTIVE';
|
|
59
|
-
copyFromRoleId?: number;
|
|
60
|
-
}, loggedInUser: UserData): Promise<{
|
|
61
|
-
success: boolean;
|
|
62
|
-
msg: string;
|
|
63
|
-
role: {
|
|
64
|
-
id: number;
|
|
65
|
-
name: string;
|
|
66
|
-
status: string;
|
|
67
|
-
code: string;
|
|
68
|
-
};
|
|
69
|
-
}>;
|
|
70
35
|
}
|
|
@@ -8,21 +8,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.ModuleAccessService = void 0;
|
|
16
13
|
const common_1 = require("@nestjs/common");
|
|
17
14
|
const module_access_repository_1 = require("../repository/module-access.repository");
|
|
18
|
-
const role_service_1 = require("../../user/service/role.service");
|
|
19
|
-
const global_constant_1 = require("../../../constant/global.constant");
|
|
20
|
-
const typeorm_1 = require("typeorm");
|
|
21
15
|
let ModuleAccessService = class ModuleAccessService {
|
|
22
|
-
constructor(moduleAccessRepository
|
|
16
|
+
constructor(moduleAccessRepository) {
|
|
23
17
|
this.moduleAccessRepository = moduleAccessRepository;
|
|
24
|
-
this.roleService = roleService;
|
|
25
|
-
this.entityManager = entityManager;
|
|
26
18
|
}
|
|
27
19
|
async getRoles() {
|
|
28
20
|
return this.moduleAccessRepository.getRoles();
|
|
@@ -48,44 +40,10 @@ let ModuleAccessService = class ModuleAccessService {
|
|
|
48
40
|
return { success: false, msg: 'Failed to update module access' };
|
|
49
41
|
}
|
|
50
42
|
}
|
|
51
|
-
async createRole(body, loggedInUser) {
|
|
52
|
-
return this.moduleAccessRepository.createRole(body, loggedInUser);
|
|
53
|
-
}
|
|
54
|
-
async updateRole(id, body, loggedInUser) {
|
|
55
|
-
if (!body.name) {
|
|
56
|
-
throw new common_1.BadRequestException('Role name is required');
|
|
57
|
-
}
|
|
58
|
-
if (body.status === 'INACTIVE') {
|
|
59
|
-
const entityData = await this.roleService.getEntityData(global_constant_1.ENTITYTYPE_ROLE, id);
|
|
60
|
-
const associatedUsers = await this.entityManager.query(`SELECT map.*
|
|
61
|
-
FROM cr_user_role_mapping map
|
|
62
|
-
JOIN cr_user usr ON map.user_id = usr.id
|
|
63
|
-
WHERE usr.status = 'ACTIVE' and map.role_id = ${entityData?.id}`);
|
|
64
|
-
if (associatedUsers.length > 0) {
|
|
65
|
-
throw new common_1.BadRequestException('Cannot deactivate role as it is associated with active users');
|
|
66
|
-
}
|
|
67
|
-
if (!entityData) {
|
|
68
|
-
throw new common_1.BadRequestException('Role not found');
|
|
69
|
-
}
|
|
70
|
-
const role = entityData;
|
|
71
|
-
if (role.is_system === 1) {
|
|
72
|
-
throw new common_1.BadRequestException('Cannot deactivate system role');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return this.moduleAccessRepository.updateRole(id, {
|
|
76
|
-
name: body.name,
|
|
77
|
-
description: body.description,
|
|
78
|
-
status: body.status,
|
|
79
|
-
copyFromRoleId: body.copyFromRoleId,
|
|
80
|
-
}, loggedInUser);
|
|
81
|
-
}
|
|
82
43
|
};
|
|
83
44
|
exports.ModuleAccessService = ModuleAccessService;
|
|
84
45
|
exports.ModuleAccessService = ModuleAccessService = __decorate([
|
|
85
46
|
(0, common_1.Injectable)(),
|
|
86
|
-
|
|
87
|
-
__metadata("design:paramtypes", [module_access_repository_1.ModuleAccessRepository,
|
|
88
|
-
role_service_1.RoleService,
|
|
89
|
-
typeorm_1.EntityManager])
|
|
47
|
+
__metadata("design:paramtypes", [module_access_repository_1.ModuleAccessRepository])
|
|
90
48
|
], ModuleAccessService);
|
|
91
49
|
//# sourceMappingURL=module-access.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-access.service.js","sourceRoot":"","sources":["../../../../src/module/module/service/module-access.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-access.service.js","sourceRoot":"","sources":["../../../../src/module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AmB,CAuC/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UserService } from '../service/user.service';
|
|
2
|
+
import { RoleService } from '../service/role.service';
|
|
3
|
+
export declare class RoleController {
|
|
4
|
+
private readonly userService;
|
|
5
|
+
private readonly roleService;
|
|
6
|
+
constructor(userService: UserService, roleService: RoleService);
|
|
7
|
+
createRole(body: {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
11
|
+
copyFromRoleId?: number;
|
|
12
|
+
}, request: Request & {
|
|
13
|
+
user: any;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
msg: string;
|
|
17
|
+
role: {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
status: string;
|
|
21
|
+
code: string;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
updateRole(id: number, body: {
|
|
25
|
+
name?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
28
|
+
copyFromRoleId?: number;
|
|
29
|
+
}, req: Request & {
|
|
30
|
+
user: any;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
msg: string;
|
|
34
|
+
role: {
|
|
35
|
+
id: number;
|
|
36
|
+
name: string;
|
|
37
|
+
status: string;
|
|
38
|
+
code: string;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RoleController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const user_service_1 = require("../service/user.service");
|
|
18
|
+
const global_constant_1 = require("../../../constant/global.constant");
|
|
19
|
+
const role_service_1 = require("../service/role.service");
|
|
20
|
+
const jwt_guard_1 = require("../../auth/guards/jwt.guard");
|
|
21
|
+
let RoleController = class RoleController {
|
|
22
|
+
constructor(userService, roleService) {
|
|
23
|
+
this.userService = userService;
|
|
24
|
+
this.roleService = roleService;
|
|
25
|
+
}
|
|
26
|
+
async createRole(body, request) {
|
|
27
|
+
let requestedUser = request.user;
|
|
28
|
+
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
29
|
+
return this.roleService.createRole(body, loggedInUser);
|
|
30
|
+
}
|
|
31
|
+
async updateRole(id, body, req) {
|
|
32
|
+
let requestedUser = req.user;
|
|
33
|
+
let loggedInUser = await this.userService.getEntityData(global_constant_1.ENTITYTYPE_USER, requestedUser.id);
|
|
34
|
+
return this.roleService.updateRole(id, body, loggedInUser);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.RoleController = RoleController;
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, common_1.Post)('create'),
|
|
40
|
+
__param(0, (0, common_1.Body)()),
|
|
41
|
+
__param(1, (0, common_1.Req)()),
|
|
42
|
+
__metadata("design:type", Function),
|
|
43
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
44
|
+
__metadata("design:returntype", Promise)
|
|
45
|
+
], RoleController.prototype, "createRole", null);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, common_1.Post)('update/:id'),
|
|
48
|
+
__param(0, (0, common_1.Param)('id')),
|
|
49
|
+
__param(1, (0, common_1.Body)()),
|
|
50
|
+
__param(2, (0, common_1.Req)()),
|
|
51
|
+
__metadata("design:type", Function),
|
|
52
|
+
__metadata("design:paramtypes", [Number, Object, Object]),
|
|
53
|
+
__metadata("design:returntype", Promise)
|
|
54
|
+
], RoleController.prototype, "updateRole", null);
|
|
55
|
+
exports.RoleController = RoleController = __decorate([
|
|
56
|
+
(0, common_1.Controller)('role'),
|
|
57
|
+
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
58
|
+
__param(0, (0, common_1.Inject)('UserService')),
|
|
59
|
+
__param(1, (0, common_1.Inject)('RoleService')),
|
|
60
|
+
__metadata("design:paramtypes", [user_service_1.UserService,
|
|
61
|
+
role_service_1.RoleService])
|
|
62
|
+
], RoleController);
|
|
63
|
+
//# sourceMappingURL=role.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role.controller.js","sourceRoot":"","sources":["../../../../src/module/user/controller/role.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuF;AACvF,0DAAsD;AACtD,uEAA+D;AAC/D,0DAAsD;AAItD,2DAAgE;AAGzD,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAC0C,WAAwB,EACxB,WAAwB;QADxB,gBAAW,GAAX,WAAW,CAAa;QACxB,gBAAW,GAAX,WAAW,CAAa;IAC/D,CAAC;IAGE,AAAN,KAAK,CAAC,UAAU,CAEd,IAKC,EACM,OAAgC;QAEvC,IAAI,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;QACjC,IAAI,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CACrD,iCAAe,EACf,aAAa,CAAC,EAAE,CACjB,CAAC;QACF,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,EAAE,YAAwB,CAAC,CAAC;IACrE,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CACD,EAAU,EAEvB,IAKC,EACM,GAA4B;QAEnC,IAAI,aAAa,GAAG,GAAG,CAAC,IAAI,CAAC;QAC7B,IAAI,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CACrD,iCAAe,EACf,aAAa,CAAC,EAAE,CACjB,CAAC;QACF,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,YAAwB,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AA5CY,wCAAc;AAOnB;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IAEZ,WAAA,IAAA,aAAI,GAAE,CAAA;IAON,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAQP;AAGK;IADL,IAAA,aAAI,EAAC,YAAY,CAAC;IAEhB,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;IAON,WAAA,IAAA,YAAG,GAAE,CAAA;;;;gDAQP;yBA3CU,cAAc;IAF1B,IAAA,mBAAU,EAAC,MAAM,CAAC;IAClB,IAAA,kBAAS,EAAC,wBAAY,CAAC;IAGnB,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;IACrB,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCAD+B,0BAAW;QACX,0BAAW;GAHvD,cAAc,CA4C1B"}
|
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
2
|
import { Role } from '../entity/role.entity';
|
|
3
|
+
import { ModuleAccess } from 'src/module/module/entity/module-access.entity';
|
|
4
|
+
import { UserData } from '../entity/user.entity';
|
|
3
5
|
export declare class RoleRepository {
|
|
4
6
|
private readonly roleRepo;
|
|
5
|
-
|
|
7
|
+
private readonly moduleAccessRepo;
|
|
8
|
+
constructor(roleRepo: Repository<Role>, moduleAccessRepo: Repository<ModuleAccess>);
|
|
6
9
|
findByCode(code: string): Promise<Role | null>;
|
|
10
|
+
createRole({ name, description, status, copyFromRoleId, }: {
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
14
|
+
copyFromRoleId?: number;
|
|
15
|
+
}, loggedInUser: UserData): Promise<{
|
|
16
|
+
success: boolean;
|
|
17
|
+
msg: string;
|
|
18
|
+
role: {
|
|
19
|
+
id: number;
|
|
20
|
+
name: string;
|
|
21
|
+
status: string;
|
|
22
|
+
code: string;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
updateRole(roleId: number, { name, description, status, copyFromRoleId, }: {
|
|
26
|
+
name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
status?: 'ACTIVE' | 'INACTIVE';
|
|
29
|
+
copyFromRoleId?: number;
|
|
30
|
+
}, loggedInUser: UserData): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
msg: string;
|
|
33
|
+
role: {
|
|
34
|
+
id: number;
|
|
35
|
+
name: string;
|
|
36
|
+
status: string;
|
|
37
|
+
code: string;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
private isRoleNameExists;
|
|
7
41
|
}
|