rez_core 6.5.41 → 6.5.43
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/core.module.js +2 -1
- package/dist/core.module.js.map +1 -1
- package/dist/module/user/entity/role.entity.js +1 -1
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/entity/user.entity.js +1 -1
- package/dist/module/user/entity/user.entity.js.map +1 -1
- package/dist/module/user/repository/role.repository.d.ts +1 -0
- package/dist/module/user/repository/role.repository.js +6 -0
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/repository/user.repository.d.ts +1 -0
- package/dist/module/user/repository/user.repository.js +6 -0
- package/dist/module/user/repository/user.repository.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +1 -1
- package/dist/module/user/service/role.service.js +10 -0
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +9 -1
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core.module.ts +2 -1
- package/src/module/user/entity/role.entity.ts +1 -1
- package/src/module/user/entity/user.entity.ts +1 -1
- package/src/module/user/repository/role.repository.ts +7 -0
- package/src/module/user/repository/user.repository.ts +7 -0
- package/src/module/user/service/role.service.ts +10 -2
- package/src/module/user/service/user.service.ts +9 -1
package/package.json
CHANGED
package/src/core.module.ts
CHANGED
|
@@ -23,7 +23,7 @@ export class Role {
|
|
|
23
23
|
@Column({ name: 'status', type: 'varchar', nullable: true, length: 100 })
|
|
24
24
|
status: string;
|
|
25
25
|
|
|
26
|
-
@Column({ name: 'code', type: 'varchar', length: 100, nullable: true })
|
|
26
|
+
@Column({ name: 'code', type: 'varchar', length: 100, nullable: true, unique: true })
|
|
27
27
|
code: string;
|
|
28
28
|
|
|
29
29
|
@Column({ name: 'created_by', type: 'bigint', nullable: true })
|
|
@@ -12,7 +12,7 @@ export class UserData {
|
|
|
12
12
|
@Column({ name: 'status', type: 'varchar', nullable: true, length: 100 })
|
|
13
13
|
status: string;
|
|
14
14
|
|
|
15
|
-
@Column({ name: 'code', type: 'varchar', length: 100, nullable: true })
|
|
15
|
+
@Column({ name: 'code', type: 'varchar', length: 100, nullable: true, unique: true })
|
|
16
16
|
code: string;
|
|
17
17
|
|
|
18
18
|
@Column({ name: 'created_by', type: 'bigint', nullable: true })
|
|
@@ -93,6 +93,13 @@ export class RoleRepository {
|
|
|
93
93
|
return this.roleRepo.findOne({ where: { id } });
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
async findMaxIdRecord() {
|
|
97
|
+
return await this.roleRepo.findOne({
|
|
98
|
+
order: { id: 'DESC' },
|
|
99
|
+
select: ['id']
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
async saveRole(role: Role) {
|
|
97
104
|
let entity = this.roleRepo.create(role);
|
|
98
105
|
return await this.roleRepo.save(entity);
|
|
@@ -67,4 +67,11 @@ export class UserRepository {
|
|
|
67
67
|
async find(options: any): Promise<UserData[]> {
|
|
68
68
|
return await this.userRepository.find(options);
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
async findMaxIdRecord() {
|
|
72
|
+
return await this.userRepository.findOne({
|
|
73
|
+
order: { id: 'DESC' },
|
|
74
|
+
select: ['id']
|
|
75
|
+
});
|
|
76
|
+
}
|
|
70
77
|
}
|
|
@@ -23,7 +23,7 @@ export class RoleService {
|
|
|
23
23
|
|
|
24
24
|
async createRole(
|
|
25
25
|
role: Role,
|
|
26
|
-
loggedInUser:
|
|
26
|
+
loggedInUser: any,
|
|
27
27
|
) {
|
|
28
28
|
|
|
29
29
|
// if level_type and level_id are not provided, use loggedInUser's values
|
|
@@ -31,7 +31,7 @@ export class RoleService {
|
|
|
31
31
|
role.level_id = role.level_id || loggedInUser.level_id;
|
|
32
32
|
role.created_by = loggedInUser.id;
|
|
33
33
|
role.enterprise_id = loggedInUser.enterprise_id;
|
|
34
|
-
|
|
34
|
+
role.app_id = role.app_id || loggedInUser.app_id;
|
|
35
35
|
|
|
36
36
|
if (
|
|
37
37
|
await this.roleRepository.isRoleNameWithLevelExists(role.name, {
|
|
@@ -45,6 +45,14 @@ export class RoleService {
|
|
|
45
45
|
return { success: false, error: 'Role name already exists.' };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
if(!role.code) {
|
|
49
|
+
const maxId = await this.roleRepository.findMaxIdRecord();
|
|
50
|
+
if(maxId && maxId.id) {
|
|
51
|
+
role.code = `ROL${maxId.id + 1}`;
|
|
52
|
+
} else {
|
|
53
|
+
role.code = `ROL1`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
const sourceRole = role.copy_from_role_id
|
|
50
58
|
? await this.roleRepository.findById(role.copy_from_role_id)
|
|
@@ -50,7 +50,15 @@ export class UserService {
|
|
|
50
50
|
if (existingUser) {
|
|
51
51
|
return { success: false, error: 'User with this mobile already exists' };
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
if(!userData.code) {
|
|
55
|
+
const maxId = await this.userRepository.findMaxIdRecord();
|
|
56
|
+
if(maxId && maxId.id) {
|
|
57
|
+
userData.code = `USR${maxId.id + 1}`;
|
|
58
|
+
} else {
|
|
59
|
+
userData.code = `USR1`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
54
62
|
|
|
55
63
|
userData.password = EncryptUtilService.encryptGCM(
|
|
56
64
|
userData.password || 'Admin@123',
|