rez_core 2.1.52 → 2.1.53

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": "2.1.52",
3
+ "version": "2.1.53",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,3 +1,4 @@
1
+ import { level } from 'winston';
1
2
  import { Injectable } from '@nestjs/common';
2
3
  import { InjectRepository } from '@nestjs/typeorm';
3
4
  import { UserRoleMapping } from '../entity/user-role-mapping.entity';
@@ -73,7 +74,15 @@ export class UserRoleMappingRepository {
73
74
  });
74
75
  }
75
76
 
76
- async deleteByUserId(userId: number) {
77
+ async deleteByUserId(userId: number, levelType?: string, levelId?: string) {
78
+ if (levelType && levelId) {
79
+ await this.userRoleMappingRepository.delete({
80
+ user_id: userId,
81
+ level_type: levelType,
82
+ level_id: levelId,
83
+ });
84
+ return;
85
+ }
77
86
  await this.userRoleMappingRepository.delete({ user_id: userId });
78
87
  }
79
88
 
@@ -16,27 +16,23 @@ export class UserRepository {
16
16
  async findByEmailId(
17
17
  email: string,
18
18
  organization_id?: number,
19
- appCode?: string,
20
19
  ): Promise<UserData | null> {
21
20
  if (!email) return null;
22
-
21
+
23
22
  const where: any = { email_id: email };
24
23
  if (organization_id !== undefined) {
25
24
  where.organization_id = organization_id;
26
25
  }
27
- if (appCode !== undefined) {
28
- where.appcode = appCode;
29
- }
30
26
  return this.userRepository.findOne({ where });
31
27
  }
32
-
28
+
33
29
  async findByMobile(
34
30
  mobile: string,
35
31
  organization_id?: number,
36
32
  appCode?: string,
37
33
  ): Promise<UserData | null> {
38
34
  if (!mobile) return null;
39
-
35
+
40
36
  const where: any = { mobile };
41
37
  if (organization_id !== undefined) {
42
38
  where.organization_id = organization_id;
@@ -44,10 +40,9 @@ export class UserRepository {
44
40
  if (appCode !== undefined) {
45
41
  where.appcode = appCode;
46
42
  }
47
-
43
+
48
44
  return this.userRepository.findOne({ where });
49
45
  }
50
-
51
46
 
52
47
  async saveUser(user: UserData): Promise<UserData> {
53
48
  return this.userRepository.save(user);
@@ -1,3 +1,4 @@
1
+ import { level } from 'winston';
1
2
  import { Injectable } from '@nestjs/common';
2
3
  import { UserRoleMappingRepository } from '../repository/user-role-mapping.repository';
3
4
  import { UserRoleMapping } from '../entity/user-role-mapping.entity';
@@ -59,8 +60,16 @@ export class UserRoleMappingService {
59
60
  return await this.userRoleMappingRepository.findByUserId(userId);
60
61
  }
61
62
 
62
- async deleteByUserId(userId: number) {
63
- await this.userRoleMappingRepository.deleteByUserId(userId);
63
+ async deleteByUserId(
64
+ userId: number,
65
+ levelType?: string,
66
+ levelId?,
67
+ ): Promise<void> {
68
+ await this.userRoleMappingRepository.deleteByUserId(
69
+ userId,
70
+ levelType,
71
+ levelId,
72
+ );
64
73
  }
65
74
 
66
75
  async getUserByIdAndAppCode(
@@ -178,7 +178,15 @@ export class UserService extends EntityServiceImpl {
178
178
 
179
179
  // Handle updated access levels
180
180
  if (userDto.access && userDto.access.length > 0) {
181
- await this.userRoleMappingService.deleteByUserId(existingUser.id);
181
+ if (loggedInUserData.level_type == 'ORG') {
182
+ await this.userRoleMappingService.deleteByUserId(existingUser.id);
183
+ } else {
184
+ await this.userRoleMappingService.deleteByUserId(
185
+ existingUser.id,
186
+ loggedInUserData.level_type,
187
+ loggedInUserData.level_id,
188
+ );
189
+ }
182
190
 
183
191
  const insertPromises: any[] = [];
184
192
 
@@ -217,13 +225,8 @@ export class UserService extends EntityServiceImpl {
217
225
  async findByEmailId(
218
226
  email_id: string,
219
227
  organization_id?: number,
220
- appCode?: string,
221
228
  ): Promise<UserData | null> {
222
- return await this.userRepository.findByEmailId(
223
- email_id,
224
- organization_id,
225
- appCode,
226
- );
229
+ return await this.userRepository.findByEmailId(email_id, organization_id);
227
230
  }
228
231
 
229
232
  async findByMobile(