rez_core 6.5.42 → 6.5.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "6.5.42",
3
+ "version": "6.5.44",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -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})
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: UserData,
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
- // role.appcode = role.appcode || loggedInUser.appcode;
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',