rez_core 1.0.48 → 1.0.49

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.
Files changed (62) hide show
  1. package/.idea/250218_nodejs_core.iml +12 -0
  2. package/.idea/codeStyles/Project.xml +59 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/dataSources.xml +12 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/prettier.xml +6 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/data/master.xlsx +0 -0
  9. package/dist/constant/global.constant.d.ts +1 -0
  10. package/dist/constant/global.constant.js +2 -1
  11. package/dist/constant/global.constant.js.map +1 -1
  12. package/dist/module/auth/guards/role.guard.js +3 -3
  13. package/dist/module/master/service/master.service.js +14 -0
  14. package/dist/module/master/service/master.service.js.map +1 -1
  15. package/dist/module/meta/controller/entity.controller.d.ts +6 -2
  16. package/dist/module/meta/controller/entity.controller.js +13 -6
  17. package/dist/module/meta/controller/entity.controller.js.map +1 -1
  18. package/dist/module/module/controller/module-access.controller.d.ts +7 -1
  19. package/dist/module/module/controller/module-access.controller.js +19 -8
  20. package/dist/module/module/controller/module-access.controller.js.map +1 -1
  21. package/dist/module/module/repository/module-access.repository.d.ts +3 -2
  22. package/dist/module/module/repository/module-access.repository.js +30 -13
  23. package/dist/module/module/repository/module-access.repository.js.map +1 -1
  24. package/dist/module/module/service/module-access.service.d.ts +6 -3
  25. package/dist/module/module/service/module-access.service.js +25 -13
  26. package/dist/module/module/service/module-access.service.js.map +1 -1
  27. package/dist/module/user/entity/user-role-mapping.entity.d.ts +1 -0
  28. package/dist/module/user/entity/user-role-mapping.entity.js +6 -0
  29. package/dist/module/user/entity/user-role-mapping.entity.js.map +1 -1
  30. package/dist/module/user/service/role.service.js.map +1 -1
  31. package/dist/tsconfig.build.tsbuildinfo +1 -1
  32. package/package.json +1 -1
  33. package/src/constant/global.constant.ts +2 -0
  34. package/src/module/auth/guards/jwt.guard.ts +22 -22
  35. package/src/module/auth/guards/role.guard.ts +68 -68
  36. package/src/module/auth/services/jwt.service.ts +11 -11
  37. package/src/module/auth/strategies/local.strategy.ts +13 -13
  38. package/src/module/dev/dev.module.ts +12 -12
  39. package/src/module/dev/service/dev.service.ts +7 -7
  40. package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
  41. package/src/module/enterprise/entity/organization.entity.ts +80 -80
  42. package/src/module/master/service/master.service.ts +14 -0
  43. package/src/module/meta/controller/entity.controller.ts +14 -3
  44. package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
  45. package/src/module/meta/entity/preference.entity.ts +65 -65
  46. package/src/module/meta/repository/preference.repository.ts +20 -20
  47. package/src/module/module/controller/menu.controller.ts +15 -15
  48. package/src/module/module/controller/module-access.controller.ts +16 -4
  49. package/src/module/module/entity/module-access.entity.ts +22 -22
  50. package/src/module/module/entity/module-action.entity.ts +19 -19
  51. package/src/module/module/repository/module-access.repository.ts +81 -47
  52. package/src/module/module/service/module-access.service.ts +39 -19
  53. package/src/module/user/controller/user.controller.ts +28 -28
  54. package/src/module/user/dto/update-user.dto.ts +4 -4
  55. package/src/module/user/entity/user-role-mapping.entity.ts +5 -0
  56. package/src/module/user/entity/user-session.entity.ts +61 -61
  57. package/src/module/user/repository/userSession.repository.ts +33 -33
  58. package/src/module/user/service/role.service.ts +1 -0
  59. package/src/resources/dev.properties.yaml +6 -6
  60. package/src/utils/service/encryptUtil.service.ts +97 -97
  61. package/src/utils/service/excelUtil.service.ts +15 -15
  62. package/src/utils/service/reflection-helper.service.ts +53 -53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -11,6 +11,8 @@ export const ENTITYTYPE_LISTMASTER = 'LMS';
11
11
  export const ENTITYTYPE_LISTMASTERITEMS = 'LMI';
12
12
  export const ENTITYTYPE_SECTIONMASTER = 'SEC';
13
13
  export const ENTITYTYPE_FIELDMASTER = 'FLD';
14
+ export const ENTITYTYPE_USRROLMAP = 'URM';
15
+
14
16
 
15
17
  export const STORAGETYPE_SINGLEJSON = 'singlejson';
16
18
  export const STORAGETYPE_COLUMN = 'column';
@@ -1,22 +1,22 @@
1
- import { ExecutionContext, Injectable } from '@nestjs/common';
2
- import { AuthGuard } from '@nestjs/passport';
3
- import { Reflector } from '@nestjs/core';
4
- import { Observable } from 'rxjs';
5
-
6
- @Injectable()
7
- export class JwtAuthGuard extends AuthGuard('jwt') {
8
- constructor(private reflector: Reflector) {
9
- super();
10
- }
11
-
12
- canActivate(
13
- context: ExecutionContext,
14
- ): Promise<boolean> | boolean | Observable<boolean> {
15
- const isPublic = this.reflector.getAllAndOverride('isPublic', [
16
- context.getHandler(),
17
- context.getClass(),
18
- ]);
19
- if (isPublic) return true;
20
- return super.canActivate(context);
21
- }
22
- }
1
+ import { ExecutionContext, Injectable } from '@nestjs/common';
2
+ import { AuthGuard } from '@nestjs/passport';
3
+ import { Reflector } from '@nestjs/core';
4
+ import { Observable } from 'rxjs';
5
+
6
+ @Injectable()
7
+ export class JwtAuthGuard extends AuthGuard('jwt') {
8
+ constructor(private reflector: Reflector) {
9
+ super();
10
+ }
11
+
12
+ canActivate(
13
+ context: ExecutionContext,
14
+ ): Promise<boolean> | boolean | Observable<boolean> {
15
+ const isPublic = this.reflector.getAllAndOverride('isPublic', [
16
+ context.getHandler(),
17
+ context.getClass(),
18
+ ]);
19
+ if (isPublic) return true;
20
+ return super.canActivate(context);
21
+ }
22
+ }
@@ -1,68 +1,68 @@
1
- import {
2
- CanActivate,
3
- ExecutionContext,
4
- ForbiddenException,
5
- Injectable,
6
- UnauthorizedException,
7
- } from '@nestjs/common';
8
- import { Reflector } from '@nestjs/core';
9
- import { UserData } from '../../user/entity/user.entity';
10
- import { InjectEntityManager } from '@nestjs/typeorm';
11
- import { EntityManager } from 'typeorm';
12
-
13
- @Injectable()
14
- export class RolesGuard implements CanActivate {
15
- constructor(
16
- private reflector: Reflector,
17
- @InjectEntityManager() private entityManager: EntityManager,
18
- ) {}
19
-
20
- async canActivate(context: ExecutionContext) {
21
- const request = context
22
- .switchToHttp()
23
- .getRequest<Request & { user: any }>();
24
- const object = request.user;
25
-
26
- const users: UserData = await this.entityManager.query(
27
- `SELECT * FROM cr_user WHERE id = ${object.userId} LIMIT 1`,
28
- );
29
-
30
- const user = users[0];
31
- if (!user || !user['role_id']) {
32
- throw new UnauthorizedException('User not authorized');
33
- }
34
-
35
- const requiredModule = this.reflector.get<string>(
36
- 'moduleCode',
37
- context.getHandler(),
38
- );
39
- const requiredActions = this.reflector.get<string>(
40
- 'actions',
41
- context.getHandler(),
42
- );
43
-
44
- const roleAccess = await this.entityManager.query(
45
- `SELECT *
46
- FROM cr_module_access
47
- WHERE role_id = ${user['role_id']}
48
- AND module_code = '${requiredModule}'`,
49
- );
50
-
51
- if (!roleAccess || roleAccess.length === 0) {
52
- throw new ForbiddenException(
53
- 'Access denied: No permissions found for this module',
54
- );
55
- }
56
-
57
- const hasAccess = roleAccess.some(
58
- (access) =>
59
- requiredActions.includes(access.action_type) &&
60
- access.access_flag === 1,
61
- );
62
-
63
- if (!hasAccess) {
64
- throw new ForbiddenException('Access denied: Insufficient permissions.');
65
- }
66
- return true;
67
- }
68
- }
1
+ import {
2
+ CanActivate,
3
+ ExecutionContext,
4
+ ForbiddenException,
5
+ Injectable,
6
+ UnauthorizedException,
7
+ } from '@nestjs/common';
8
+ import { Reflector } from '@nestjs/core';
9
+ import { UserData } from '../../user/entity/user.entity';
10
+ import { InjectEntityManager } from '@nestjs/typeorm';
11
+ import { EntityManager } from 'typeorm';
12
+
13
+ @Injectable()
14
+ export class RolesGuard implements CanActivate {
15
+ constructor(
16
+ private reflector: Reflector,
17
+ @InjectEntityManager() private entityManager: EntityManager,
18
+ ) {}
19
+
20
+ async canActivate(context: ExecutionContext) {
21
+ const request = context
22
+ .switchToHttp()
23
+ .getRequest<Request & { user: any }>();
24
+ const object = request.user;
25
+
26
+ const users: UserData = await this.entityManager.query(
27
+ `SELECT * FROM cr_user WHERE id = ${object.userId} LIMIT 1`,
28
+ );
29
+
30
+ const user = users[0];
31
+ if (!user || !user['role_id']) {
32
+ throw new UnauthorizedException('User not authorized');
33
+ }
34
+
35
+ const requiredModule = this.reflector.get<string>(
36
+ 'moduleCode',
37
+ context.getHandler(),
38
+ );
39
+ const requiredActions = this.reflector.get<string>(
40
+ 'actions',
41
+ context.getHandler(),
42
+ );
43
+
44
+ const roleAccess = await this.entityManager.query(
45
+ `SELECT *
46
+ FROM cr_module_access
47
+ WHERE role_id = ${user['role_id']}
48
+ AND module_code = '${requiredModule}'`,
49
+ );
50
+
51
+ if (!roleAccess || roleAccess.length === 0) {
52
+ throw new ForbiddenException(
53
+ 'Access denied: No permissions found for this module',
54
+ );
55
+ }
56
+
57
+ const hasAccess = roleAccess.some(
58
+ (access) =>
59
+ requiredActions.includes(access.action_type) &&
60
+ access.access_flag === 1,
61
+ );
62
+
63
+ if (!hasAccess) {
64
+ throw new ForbiddenException('Access denied: Insufficient permissions.');
65
+ }
66
+ return true;
67
+ }
68
+ }
@@ -1,11 +1,11 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { JwtService } from '@nestjs/jwt';
3
-
4
- @Injectable()
5
- export class JwtAuthService {
6
- constructor(private readonly jwtService: JwtService) {}
7
-
8
- generateJwt(payload: any): string {
9
- return this.jwtService.sign(payload);
10
- }
11
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { JwtService } from '@nestjs/jwt';
3
+
4
+ @Injectable()
5
+ export class JwtAuthService {
6
+ constructor(private readonly jwtService: JwtService) {}
7
+
8
+ generateJwt(payload: any): string {
9
+ return this.jwtService.sign(payload);
10
+ }
11
+ }
@@ -1,13 +1,13 @@
1
- import { PassportStrategy } from '@nestjs/passport';
2
- import { AuthService } from '../services/auth.service';
3
- import { Injectable } from '@nestjs/common';
4
- import { Strategy } from 'passport-jwt';
5
-
6
- @Injectable()
7
- export class LocalStrategy extends PassportStrategy(Strategy) {
8
- constructor(private authService: AuthService) {
9
- super({
10
- usernameField: 'email',
11
- });
12
- }
13
- }
1
+ import { PassportStrategy } from '@nestjs/passport';
2
+ import { AuthService } from '../services/auth.service';
3
+ import { Injectable } from '@nestjs/common';
4
+ import { Strategy } from 'passport-jwt';
5
+
6
+ @Injectable()
7
+ export class LocalStrategy extends PassportStrategy(Strategy) {
8
+ constructor(private authService: AuthService) {
9
+ super({
10
+ usernameField: 'email',
11
+ });
12
+ }
13
+ }
@@ -1,12 +1,12 @@
1
- import { Module } from '@nestjs/common';
2
- import { EntityModule } from '../meta/entity.module';
3
- import { UserModule } from '../user/user.module';
4
- import { ModuleModule } from '../module/module.module';
5
- import { DevService } from './service/dev.service';
6
-
7
- @Module({
8
- imports: [EntityModule, UserModule, ModuleModule],
9
- controllers: [],
10
- providers: [DevService],
11
- })
12
- export class DevModule {}
1
+ import { Module } from '@nestjs/common';
2
+ import { EntityModule } from '../meta/entity.module';
3
+ import { UserModule } from '../user/user.module';
4
+ import { ModuleModule } from '../module/module.module';
5
+ import { DevService } from './service/dev.service';
6
+
7
+ @Module({
8
+ imports: [EntityModule, UserModule, ModuleModule],
9
+ controllers: [],
10
+ providers: [DevService],
11
+ })
12
+ export class DevModule {}
@@ -1,7 +1,7 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { UserService } from '../../user/service/user.service';
3
-
4
- @Injectable()
5
- export class DevService {
6
- constructor(private readonly userService: UserService) {}
7
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { UserService } from '../../user/service/user.service';
3
+
4
+ @Injectable()
5
+ export class DevService {
6
+ constructor(private readonly userService: UserService) {}
7
+ }
@@ -1,37 +1,37 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_enterprise' })
4
- export class EnterpriseData {
5
- @PrimaryGeneratedColumn({ name: 'id', type: 'bigint' })
6
- id: number;
7
-
8
- @Column({ name: 'entity_type', type: 'varchar', nullable: true, length: 50 })
9
- entityType: string;
10
-
11
- @Column({ name: 'code', type: 'varchar', nullable: true, length: 50 })
12
- code: string;
13
-
14
- @Column({ name: 'name', type: 'varchar', nullable: true, length: 50 })
15
- name: string;
16
-
17
- @Column({ name: 'status', type: 'varchar', nullable: true, length: 50 })
18
- status: string;
19
-
20
- @Column({ name: 'created_by', type: 'int', nullable: true })
21
- createdBy: number;
22
-
23
- @Column({ name: 'modified_by', type: 'int', nullable: true })
24
- modifiedBy: number;
25
-
26
- @Column({ name: 'created_date', type: 'datetime', nullable: true })
27
- createdDate: Date;
28
-
29
- @Column({ name: 'modified_date', type: 'datetime', nullable: true })
30
- modifiedDate: Date;
31
-
32
- @Column({ name: 'app_code', type: 'varchar', nullable: true, length: 50 })
33
- appCode: string;
34
-
35
- @Column({ name: 'app_url_name', type: 'varchar', nullable: true, length: 50 })
36
- appUrlName: string;
37
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_enterprise' })
4
+ export class EnterpriseData {
5
+ @PrimaryGeneratedColumn({ name: 'id', type: 'bigint' })
6
+ id: number;
7
+
8
+ @Column({ name: 'entity_type', type: 'varchar', nullable: true, length: 50 })
9
+ entityType: string;
10
+
11
+ @Column({ name: 'code', type: 'varchar', nullable: true, length: 50 })
12
+ code: string;
13
+
14
+ @Column({ name: 'name', type: 'varchar', nullable: true, length: 50 })
15
+ name: string;
16
+
17
+ @Column({ name: 'status', type: 'varchar', nullable: true, length: 50 })
18
+ status: string;
19
+
20
+ @Column({ name: 'created_by', type: 'int', nullable: true })
21
+ createdBy: number;
22
+
23
+ @Column({ name: 'modified_by', type: 'int', nullable: true })
24
+ modifiedBy: number;
25
+
26
+ @Column({ name: 'created_date', type: 'datetime', nullable: true })
27
+ createdDate: Date;
28
+
29
+ @Column({ name: 'modified_date', type: 'datetime', nullable: true })
30
+ modifiedDate: Date;
31
+
32
+ @Column({ name: 'app_code', type: 'varchar', nullable: true, length: 50 })
33
+ appCode: string;
34
+
35
+ @Column({ name: 'app_url_name', type: 'varchar', nullable: true, length: 50 })
36
+ appUrlName: string;
37
+ }
@@ -1,80 +1,80 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_organization' })
4
- export class OrganizationData {
5
- @PrimaryGeneratedColumn({ name: 'id', type: 'int' })
6
- id: number;
7
-
8
- @Column({ name: 'enterprise_id', type: 'int' })
9
- enterprise_id: number;
10
-
11
- @Column({ name: 'code', nullable: true })
12
- code: string;
13
-
14
- @Column({ name: 'app_code', nullable: true })
15
- appCode: string;
16
-
17
- @Column({ name: 'name', nullable: true })
18
- name: string;
19
-
20
- @Column({ name: 'status', type: 'varchar', nullable: true })
21
- status: string;
22
-
23
- @Column({ name: 'seq_no', nullable: true })
24
- seq_no: number;
25
-
26
- @Column({ name: 'created_by', nullable: true })
27
- created_by: number;
28
-
29
- @Column({ name: 'modified_by', nullable: true })
30
- modified_by: number;
31
-
32
- @Column({ name: 'created_date', nullable: true })
33
- created_date: Date;
34
-
35
- @Column({ name: 'parent_id', nullable: true })
36
- parent_id: number;
37
-
38
- @Column({ name: 'modified_date', nullable: true })
39
- modified_date: Date;
40
-
41
- @Column({ name: 'contact_number', nullable: true })
42
- contact_number: string;
43
-
44
- @Column({ name: 'email', nullable: true })
45
- emailId: string;
46
-
47
- @Column({ name: 'entity_type', nullable: true })
48
- entity_type: string;
49
-
50
- @Column({ name: 'primary_contact_name', nullable: true })
51
- primary_contact_name: string;
52
-
53
- @Column({ name: 'address', nullable: true })
54
- address: string;
55
-
56
- @Column({ name: 'gstin', nullable: true })
57
- gstin: string;
58
-
59
- @Column({ name: 'company_pan_number', nullable: true })
60
- company_pan_number: string;
61
-
62
- @Column({ name: 'bankacc_benef_name', nullable: true })
63
- bankacc_benef_name: string;
64
-
65
- @Column({ name: 'bankacc_bank_name', nullable: true })
66
- bankacc_bank_name: string;
67
-
68
- @Column({ name: 'bankacc_account_number', nullable: true })
69
- bankaccAccountNumber: string;
70
-
71
- @Column({ name: 'bankacc_branch_IFSC', nullable: true })
72
- bankacc_account_number: string;
73
-
74
- @Column({
75
- name: 'organization_type',
76
- type: 'varchar',
77
- nullable: true,
78
- })
79
- organization_type: string;
80
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_organization' })
4
+ export class OrganizationData {
5
+ @PrimaryGeneratedColumn({ name: 'id', type: 'int' })
6
+ id: number;
7
+
8
+ @Column({ name: 'enterprise_id', type: 'int' })
9
+ enterprise_id: number;
10
+
11
+ @Column({ name: 'code', nullable: true })
12
+ code: string;
13
+
14
+ @Column({ name: 'app_code', nullable: true })
15
+ appCode: string;
16
+
17
+ @Column({ name: 'name', nullable: true })
18
+ name: string;
19
+
20
+ @Column({ name: 'status', type: 'varchar', nullable: true })
21
+ status: string;
22
+
23
+ @Column({ name: 'seq_no', nullable: true })
24
+ seq_no: number;
25
+
26
+ @Column({ name: 'created_by', nullable: true })
27
+ created_by: number;
28
+
29
+ @Column({ name: 'modified_by', nullable: true })
30
+ modified_by: number;
31
+
32
+ @Column({ name: 'created_date', nullable: true })
33
+ created_date: Date;
34
+
35
+ @Column({ name: 'parent_id', nullable: true })
36
+ parent_id: number;
37
+
38
+ @Column({ name: 'modified_date', nullable: true })
39
+ modified_date: Date;
40
+
41
+ @Column({ name: 'contact_number', nullable: true })
42
+ contact_number: string;
43
+
44
+ @Column({ name: 'email', nullable: true })
45
+ emailId: string;
46
+
47
+ @Column({ name: 'entity_type', nullable: true })
48
+ entity_type: string;
49
+
50
+ @Column({ name: 'primary_contact_name', nullable: true })
51
+ primary_contact_name: string;
52
+
53
+ @Column({ name: 'address', nullable: true })
54
+ address: string;
55
+
56
+ @Column({ name: 'gstin', nullable: true })
57
+ gstin: string;
58
+
59
+ @Column({ name: 'company_pan_number', nullable: true })
60
+ company_pan_number: string;
61
+
62
+ @Column({ name: 'bankacc_benef_name', nullable: true })
63
+ bankacc_benef_name: string;
64
+
65
+ @Column({ name: 'bankacc_bank_name', nullable: true })
66
+ bankacc_bank_name: string;
67
+
68
+ @Column({ name: 'bankacc_account_number', nullable: true })
69
+ bankaccAccountNumber: string;
70
+
71
+ @Column({ name: 'bankacc_branch_IFSC', nullable: true })
72
+ bankacc_account_number: string;
73
+
74
+ @Column({
75
+ name: 'organization_type',
76
+ type: 'varchar',
77
+ nullable: true,
78
+ })
79
+ organization_type: string;
80
+ }
@@ -48,6 +48,18 @@ export class MasterService {
48
48
  ];
49
49
 
50
50
  private readonly dataSequence = [
51
+ {
52
+ table: 'cr_user',
53
+ unique_fields: ['code'],
54
+ },
55
+ {
56
+ table: 'cr_role',
57
+ unique_fields: ['code'],
58
+ },
59
+ {
60
+ table: 'cr_user_role_mapping',
61
+ unique_fields: ['user_id', 'role_id'],
62
+ },
51
63
  {
52
64
  table: 'eth_school',
53
65
  unique_fields: ['code'],
@@ -127,6 +139,7 @@ export class MasterService {
127
139
  entityMasterData?.mapped_entity_type,
128
140
  );
129
141
 
142
+ console.log(attributes,"((((((((((((((((((((((((((")
130
143
  for (const row of sheetData) {
131
144
  if (row.parent_type !== undefined && row.parent_id !== undefined) {
132
145
  this.resolveParent(row);
@@ -134,6 +147,7 @@ export class MasterService {
134
147
 
135
148
  for (const attribute of attributes) {
136
149
  if (attribute.data_source_type === 'entity') {
150
+ console.log(attribute.data_source_type)
137
151
  let entityMaster = await this.entityMasterService.getEntityData(
138
152
  attribute.datasource_list,
139
153
  );
@@ -8,7 +8,8 @@ import {
8
8
  Post,
9
9
  Query,
10
10
  Res,
11
- UseGuards,
11
+ Req,
12
+ UseGuards, Inject,
12
13
  } from '@nestjs/common';
13
14
  import { EntityServiceImpl } from '../service/entity-service-impl.service';
14
15
  import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
@@ -18,6 +19,9 @@ import { BaseEntity } from '../entity/base-entity.entity';
18
19
  import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
19
20
  import * as fs from 'fs';
20
21
  import * as path from 'path';
22
+ import { UserService } from '../../user/service/user.service';
23
+ import { ENTITYTYPE_USER } from '../../../constant/global.constant';
24
+ import { UserData } from '../../user/entity/user.entity';
21
25
 
22
26
  @UseGuards(JwtAuthGuard)
23
27
  @Controller('entity')
@@ -58,7 +62,11 @@ export class EntityController {
58
62
  @Body() entityData: BaseEntity,
59
63
  @Query('entity_type') entityType: string,
60
64
  @Res() res: Response,
65
+ @Req() req: Request & {user: any}
61
66
  ) {
67
+ let requestedUser = req.user;
68
+ let loggedInUser = await this.entityService.getEntityData(ENTITYTYPE_USER,requestedUser.id);
69
+
62
70
  if (!entityType) {
63
71
  throw new BadRequestException(
64
72
  'Query parameter "entity_type" is required',
@@ -75,7 +83,7 @@ export class EntityController {
75
83
  if (entityService) {
76
84
  return res
77
85
  .status(HttpStatus.OK)
78
- .json(await entityService.createEntity(entityData, null));
86
+ .json(await entityService.createEntity(entityData, loggedInUser as UserData));
79
87
  }
80
88
  }
81
89
 
@@ -85,7 +93,10 @@ export class EntityController {
85
93
  @Body() entityData: BaseEntity,
86
94
  @Query('entity_type') entityType: string,
87
95
  @Res() response: Response,
96
+ @Req() req: Request & {user: any}
88
97
  ) {
98
+ let requestedUser = req.user;
99
+ let loggedInUser = await this.entityService.getEntityData(ENTITYTYPE_USER,requestedUser.id);
89
100
  if (!entityType) {
90
101
  throw new BadRequestException(
91
102
  'Query parameter "entity_type" is required',
@@ -106,7 +117,7 @@ export class EntityController {
106
117
  }
107
118
  // let mergeEntity = JsonUtil.merge(existingEntity, entityData);
108
119
 
109
- entityData = await entityService.updateEntity(entityData, null);
120
+ entityData = await entityService.updateEntity(entityData, loggedInUser as UserData);
110
121
  return response.status(HttpStatus.OK).json(entityData);
111
122
  }
112
123
  }
@@ -1,6 +1,6 @@
1
- import { EntityTab } from './entity-tab.dto';
2
-
3
- export class EntityListData {
4
- entity_list: any;
5
- entity_tabs: EntityTab[];
6
- }
1
+ import { EntityTab } from './entity-tab.dto';
2
+
3
+ export class EntityListData {
4
+ entity_list: any;
5
+ entity_tabs: EntityTab[];
6
+ }