rez_core 1.0.47 → 1.0.48

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 (99) hide show
  1. package/dist/constant/global.constant.d.ts +2 -0
  2. package/dist/constant/global.constant.js +3 -1
  3. package/dist/constant/global.constant.js.map +1 -1
  4. package/dist/module/auth/guards/role.guard.js +3 -3
  5. package/dist/module/master/service/master.service.d.ts +7 -1
  6. package/dist/module/master/service/master.service.js +58 -3
  7. package/dist/module/master/service/master.service.js.map +1 -1
  8. package/dist/module/meta/controller/media.controller.d.ts +1 -0
  9. package/dist/module/meta/controller/media.controller.js +27 -0
  10. package/dist/module/meta/controller/media.controller.js.map +1 -1
  11. package/dist/module/meta/entity/field-group.entity.d.ts +9 -0
  12. package/dist/module/meta/entity/field-group.entity.js +47 -0
  13. package/dist/module/meta/entity/field-group.entity.js.map +1 -0
  14. package/dist/module/meta/entity/school.entity.d.ts +8 -0
  15. package/dist/module/meta/entity/school.entity.js +44 -0
  16. package/dist/module/meta/entity/school.entity.js.map +1 -0
  17. package/dist/module/meta/entity/schoolAddress.entity.d.ts +9 -0
  18. package/dist/module/meta/entity/schoolAddress.entity.js +48 -0
  19. package/dist/module/meta/entity/schoolAddress.entity.js.map +1 -0
  20. package/dist/module/meta/entity/section-master.entity.d.ts +10 -0
  21. package/dist/module/meta/entity/section-master.entity.js +51 -0
  22. package/dist/module/meta/entity/section-master.entity.js.map +1 -0
  23. package/dist/module/meta/entity.module.js +19 -0
  24. package/dist/module/meta/entity.module.js.map +1 -1
  25. package/dist/module/meta/repository/attribute-master.repository.d.ts +1 -0
  26. package/dist/module/meta/repository/attribute-master.repository.js +7 -0
  27. package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
  28. package/dist/module/meta/service/attribute-master.service.d.ts +6 -0
  29. package/dist/module/meta/service/attribute-master.service.js +28 -0
  30. package/dist/module/meta/service/attribute-master.service.js.map +1 -0
  31. package/dist/module/meta/service/entity-list.service.js +1 -1
  32. package/dist/module/meta/service/entity-list.service.js.map +1 -1
  33. package/dist/module/meta/service/entity-master.service.d.ts +1 -0
  34. package/dist/module/meta/service/entity-master.service.js +6 -0
  35. package/dist/module/meta/service/entity-master.service.js.map +1 -1
  36. package/dist/module/meta/service/field-group.service.d.ts +26 -0
  37. package/dist/module/meta/service/field-group.service.js +78 -0
  38. package/dist/module/meta/service/field-group.service.js.map +1 -0
  39. package/dist/module/meta/service/media-data.service.d.ts +1 -0
  40. package/dist/module/meta/service/media-data.service.js +15 -0
  41. package/dist/module/meta/service/media-data.service.js.map +1 -1
  42. package/dist/module/meta/service/section-master.service.d.ts +26 -0
  43. package/dist/module/meta/service/section-master.service.js +78 -0
  44. package/dist/module/meta/service/section-master.service.js.map +1 -0
  45. package/dist/module/meta/service/view-master.service.d.ts +5 -1
  46. package/dist/module/meta/service/view-master.service.js +32 -2
  47. package/dist/module/meta/service/view-master.service.js.map +1 -1
  48. package/dist/module/module/service/module-access.service.d.ts +3 -1
  49. package/dist/module/module/service/module-access.service.js +19 -3
  50. package/dist/module/module/service/module-access.service.js.map +1 -1
  51. package/dist/tsconfig.build.tsbuildinfo +1 -1
  52. package/package.json +1 -1
  53. package/src/constant/global.constant.ts +3 -1
  54. package/src/module/auth/guards/jwt.guard.ts +22 -22
  55. package/src/module/auth/guards/role.guard.ts +68 -68
  56. package/src/module/auth/services/jwt.service.ts +11 -11
  57. package/src/module/auth/strategies/local.strategy.ts +13 -13
  58. package/src/module/dev/dev.module.ts +12 -12
  59. package/src/module/dev/service/dev.service.ts +7 -7
  60. package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
  61. package/src/module/enterprise/entity/organization.entity.ts +80 -80
  62. package/src/module/master/service/master.service.ts +84 -3
  63. package/src/module/meta/controller/media.controller.ts +27 -1
  64. package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
  65. package/src/module/meta/entity/field-group.entity.ts +25 -0
  66. package/src/module/meta/entity/preference.entity.ts +65 -65
  67. package/src/module/meta/entity/school.entity.ts +23 -0
  68. package/src/module/meta/entity/schoolAddress.entity.ts +25 -0
  69. package/src/module/meta/entity/section-master.entity.ts +28 -0
  70. package/src/module/meta/entity.module.ts +19 -0
  71. package/src/module/meta/repository/attribute-master.repository.ts +11 -1
  72. package/src/module/meta/repository/preference.repository.ts +20 -20
  73. package/src/module/meta/service/attribute-master.service.ts +17 -0
  74. package/src/module/meta/service/entity-list.service.ts +1 -1
  75. package/src/module/meta/service/entity-master.service.ts +7 -0
  76. package/src/module/meta/service/field-group.service.ts +104 -0
  77. package/src/module/meta/service/media-data.service.ts +22 -9
  78. package/src/module/meta/service/section-master.service.ts +104 -0
  79. package/src/module/meta/service/view-master.service.ts +42 -4
  80. package/src/module/module/controller/menu.controller.ts +15 -15
  81. package/src/module/module/entity/module-access.entity.ts +22 -22
  82. package/src/module/module/entity/module-action.entity.ts +19 -19
  83. package/src/module/module/service/module-access.service.ts +32 -13
  84. package/src/module/user/controller/user.controller.ts +28 -28
  85. package/src/module/user/dto/update-user.dto.ts +4 -4
  86. package/src/module/user/entity/user-role-mapping.entity.ts +21 -21
  87. package/src/module/user/entity/user-session.entity.ts +61 -61
  88. package/src/module/user/repository/userSession.repository.ts +33 -33
  89. package/src/resources/dev.properties.yaml +2 -2
  90. package/src/utils/service/encryptUtil.service.ts +97 -97
  91. package/src/utils/service/excelUtil.service.ts +15 -15
  92. package/src/utils/service/reflection-helper.service.ts +53 -53
  93. package/.idea/250218_nodejs_core.iml +0 -12
  94. package/.idea/codeStyles/Project.xml +0 -59
  95. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  96. package/.idea/dataSources.xml +0 -12
  97. package/.idea/modules.xml +0 -8
  98. package/.idea/prettier.xml +0 -6
  99. package/.idea/vcs.xml +0 -6
@@ -0,0 +1,104 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from './entity-service-impl.service';
3
+ import { BaseEntity } from '../entity/base-entity.entity';
4
+ import { UserData } from '../../user/entity/user.entity';
5
+ import { EntityManager } from 'typeorm';
6
+ import { ViewMaster } from '../entity/view-master.entity';
7
+
8
+ @Injectable()
9
+ export class SectionMasterService extends EntityServiceImpl {
10
+ constructor() {
11
+ super();
12
+ }
13
+
14
+ async createEntity(
15
+ entityData: BaseEntity,
16
+ loggedInUser: UserData | null,
17
+ manager?: EntityManager,
18
+ ): Promise<BaseEntity> {
19
+ const entityMaster = await this.entityMasterService.getEntityData(
20
+ entityData.entity_type,
21
+ );
22
+ entityData.parent_id = entityMaster.id;
23
+ entityData.parent_type = entityMaster.entity_type;
24
+
25
+ const savedEntity = await super.createEntity(
26
+ entityData,
27
+ loggedInUser,
28
+ manager,
29
+ );
30
+ return savedEntity;
31
+ }
32
+
33
+ async updateEntity(
34
+ entityData: ViewMaster,
35
+ loggedInUserData: UserData | null,
36
+ ): Promise<BaseEntity> {
37
+ return entityData;
38
+ }
39
+
40
+ parseLayout(layoutJson: any) {
41
+ const stepsData: {
42
+ stepType: string;
43
+ stepId: string;
44
+ stepLabel: string;
45
+ stepPosition: number;
46
+ fieldsGroup: {
47
+ type: string;
48
+ label: string;
49
+ id: string;
50
+ }[];
51
+ }[] = [];
52
+
53
+ if (layoutJson?.form?.children && Array.isArray(layoutJson.form.children)) {
54
+ const firstChild = layoutJson.form.children[0];
55
+ console.log('First Child:', firstChild);
56
+
57
+ if (firstChild.type === 'wizard' && Array.isArray(firstChild.steps)) {
58
+ console.log('Wizard Steps:', firstChild.steps);
59
+ let i = 0;
60
+ for (const step of firstChild.steps) {
61
+ if (step.type === 'step') {
62
+ const fields = this.extractFields(step.fields);
63
+
64
+ stepsData.push({
65
+ stepType: step.type,
66
+ stepId: step.id,
67
+ stepLabel: step.label,
68
+ stepPosition: ++i,
69
+ fieldsGroup: fields,
70
+ });
71
+ }
72
+ }
73
+ }
74
+ }
75
+ return stepsData;
76
+ }
77
+
78
+ extractFields(fieldsArray: any[]): {
79
+ type: string;
80
+ label: string;
81
+ id: string;
82
+ }[] {
83
+ const extractedFields: { type: string; label: string; id: string }[] = [];
84
+
85
+ function traverse(fields: any[]) {
86
+ for (const field of fields) {
87
+ if (field.type === 'field-set') {
88
+ extractedFields.push({
89
+ type: field.type || 'Default Type',
90
+ label: field.label || 'Default Label',
91
+ id: field.id || 'Default ID',
92
+ });
93
+ }
94
+ if (Array.isArray(field.fields)) {
95
+ traverse(field.fields);
96
+ }
97
+ }
98
+ }
99
+
100
+ traverse(fieldsArray);
101
+
102
+ return extractedFields;
103
+ }
104
+ }
@@ -4,10 +4,16 @@ import { BaseEntity } from '../entity/base-entity.entity';
4
4
  import { UserData } from '../../user/entity/user.entity';
5
5
  import { EntityManager } from 'typeorm';
6
6
  import { ViewMaster } from '../entity/view-master.entity';
7
-
7
+ import { SectionMasterService } from './section-master.service';
8
+ import { SectionMaster } from '../entity/section-master.entity';
9
+ import { FieldGroup } from '../entity/field-group.entity';
10
+ import { FieldGroupService } from './field-group.service';
8
11
  @Injectable()
9
12
  export class ViewMasterService extends EntityServiceImpl {
10
- constructor() {
13
+ constructor(
14
+ private readonly sectionMasterService: SectionMasterService,
15
+ private readonly fieldGroupService: FieldGroupService,
16
+ ) {
11
17
  super();
12
18
  }
13
19
 
@@ -27,6 +33,40 @@ export class ViewMasterService extends EntityServiceImpl {
27
33
  loggedInUser,
28
34
  manager,
29
35
  );
36
+ let viewMaster = savedEntity as ViewMaster;
37
+
38
+ let layout = viewMaster.published_form_layout;
39
+
40
+ const stepsData = this.sectionMasterService.parseLayout(layout);
41
+ for (var step of stepsData) {
42
+ let sectionMaster = new SectionMaster();
43
+ sectionMaster.name = step.stepLabel;
44
+ sectionMaster.position = step.stepPosition;
45
+ sectionMaster.description = step.stepLabel;
46
+ sectionMaster.parent_id = viewMaster.id;
47
+ sectionMaster.parent_type = viewMaster.entity_type;
48
+
49
+ const savedSectionMaster = await this.sectionMasterService.createEntity(
50
+ sectionMaster,
51
+ loggedInUser,
52
+ manager,
53
+ );
54
+
55
+ const fieldGroups = step.fieldsGroup;
56
+ console.log('fieldGroups', fieldGroups);
57
+
58
+ for (var fieldGroup of fieldGroups) {
59
+ let fieldsGroup = new FieldGroup();
60
+ fieldsGroup.view_id = viewMaster.id;
61
+ fieldsGroup.parent_id = savedSectionMaster.id;
62
+ fieldsGroup.field_type = fieldGroup.type;
63
+ fieldsGroup.label = fieldGroup.label;
64
+ fieldsGroup.description = fieldGroup.label;
65
+
66
+ this.fieldGroupService.createEntity(fieldsGroup, loggedInUser, manager);
67
+ }
68
+ }
69
+
30
70
  return savedEntity;
31
71
  }
32
72
 
@@ -34,8 +74,6 @@ export class ViewMasterService extends EntityServiceImpl {
34
74
  entityData: ViewMaster,
35
75
  loggedInUserData: UserData | null,
36
76
  ): Promise<BaseEntity> {
37
-
38
77
  return entityData;
39
78
  }
40
-
41
79
  }
@@ -1,15 +1,15 @@
1
- import { Controller, Get, Request, UseGuards } from '@nestjs/common';
2
- import { MenuService } from '../service/menu.service';
3
- import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
4
-
5
- @Controller('menu')
6
- export class MenuController {
7
- constructor(private readonly menuService: MenuService) {}
8
-
9
- @UseGuards(JwtAuthGuard)
10
- @Get()
11
- async getMenu(@Request() req) {
12
- const userId = req.user.userId;
13
- return this.menuService.getUserMenu(userId);
14
- }
15
- }
1
+ import { Controller, Get, Request, UseGuards } from '@nestjs/common';
2
+ import { MenuService } from '../service/menu.service';
3
+ import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
4
+
5
+ @Controller('menu')
6
+ export class MenuController {
7
+ constructor(private readonly menuService: MenuService) {}
8
+
9
+ @UseGuards(JwtAuthGuard)
10
+ @Get()
11
+ async getMenu(@Request() req) {
12
+ const userId = req.user.userId;
13
+ return this.menuService.getUserMenu(userId);
14
+ }
15
+ }
@@ -1,22 +1,22 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_module_access' })
4
- export class ModuleAccess {
5
- @PrimaryGeneratedColumn()
6
- id: number;
7
-
8
- @Column({type: 'varchar', length: 100, nullable: true})
9
- module_code: string;
10
-
11
- @Column({type: 'varchar', length: 100, nullable: true })
12
- role_code: string;
13
-
14
- @Column({type: 'int', nullable: true })
15
- access_flag: number;
16
-
17
- @Column({type: 'varchar', length: 100, nullable: true })
18
- action_type: string;
19
-
20
- @Column({type: 'varchar', length: 100, nullable: true})
21
- app_code: string;
22
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_module_access' })
4
+ export class ModuleAccess {
5
+ @PrimaryGeneratedColumn()
6
+ id: number;
7
+
8
+ @Column({type: 'varchar', length: 100, nullable: true})
9
+ module_code: string;
10
+
11
+ @Column({type: 'varchar', length: 100, nullable: true })
12
+ role_code: string;
13
+
14
+ @Column({type: 'int', nullable: true })
15
+ access_flag: number;
16
+
17
+ @Column({type: 'varchar', length: 100, nullable: true })
18
+ action_type: string;
19
+
20
+ @Column({type: 'varchar', length: 100, nullable: true})
21
+ app_code: string;
22
+ }
@@ -1,19 +1,19 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'module_action' })
4
- export class ModuleAction {
5
- @PrimaryGeneratedColumn()
6
- id: number;
7
-
8
- @Column({type: 'int', nullable: true})
9
- module_id: number;
10
-
11
- @Column({type: 'varchar', length: 100, nullable: true })
12
- module_code: string;
13
-
14
- @Column({type: 'varchar', length: 100, nullable: true })
15
- action_name:string
16
-
17
- @Column({type: 'varchar', length: 50, nullable: true })
18
- action_type: string;
19
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'module_action' })
4
+ export class ModuleAction {
5
+ @PrimaryGeneratedColumn()
6
+ id: number;
7
+
8
+ @Column({type: 'int', nullable: true})
9
+ module_id: number;
10
+
11
+ @Column({type: 'varchar', length: 100, nullable: true })
12
+ module_code: string;
13
+
14
+ @Column({type: 'varchar', length: 100, nullable: true })
15
+ action_name:string
16
+
17
+ @Column({type: 'varchar', length: 50, nullable: true })
18
+ action_type: string;
19
+ }
@@ -1,10 +1,15 @@
1
- import { Injectable } from '@nestjs/common';
1
+ import { BadRequestException, Inject, Injectable } from '@nestjs/common';
2
2
  import { ModuleAccessRepository } from '../repository/module-access.repository';
3
+ import { RoleRepository } from 'src/module/user/repository/role.repository';
4
+ import { RoleService } from '../../user/service/role.service';
5
+ import { ENTITYTYPE_ROLE } from '../../../constant/global.constant';
6
+ import { Role } from '../../user/entity/role.entity';
3
7
 
4
8
  @Injectable()
5
9
  export class ModuleAccessService {
6
10
  constructor(
7
11
  private readonly moduleAccessRepository: ModuleAccessRepository,
12
+ @Inject('RoleService') private readonly roleService: RoleService,
8
13
  ) {}
9
14
 
10
15
  async getRoles() {
@@ -49,16 +54,33 @@ export class ModuleAccessService {
49
54
  return this.moduleAccessRepository.createRole(body);
50
55
  }
51
56
 
52
- async updateRole(id: number, body: {
53
- name?: string;
54
- description?: string;
55
- status?: 'ACTIVE' | 'INACTIVE';
56
- copyFromRoleId?: number;
57
- }) {
57
+ async updateRole(
58
+ id: number,
59
+ body: {
60
+ name?: string;
61
+ description?: string;
62
+ status?: 'ACTIVE' | 'INACTIVE';
63
+ copyFromRoleId?: number;
64
+ },
65
+ ) {
58
66
  if (!body.name) {
59
- throw new Error('Role name is required');
67
+ throw new BadRequestException('Role name is required');
68
+ }
69
+
70
+ //get role by id
71
+ const entityData = await this.roleService.getEntityData(ENTITYTYPE_ROLE,id);
72
+
73
+ if (!entityData) {
74
+ throw new BadRequestException('Role not found');
75
+ }
76
+ const role = entityData as Role;
77
+ if (body.status === 'INACTIVE' && role.is_system === 1) {
78
+ throw new BadRequestException('Cannot deactivate system role');
60
79
  }
61
-
80
+
81
+ //if body.status =="INACTIVE" and role.is_system==1:
82
+ // throw new Error('Cannot deactivate system role');
83
+
62
84
  return this.moduleAccessRepository.updateRole(id, {
63
85
  name: body.name,
64
86
  description: body.description,
@@ -66,7 +88,4 @@ export class ModuleAccessService {
66
88
  copyFromRoleId: body.copyFromRoleId,
67
89
  });
68
90
  }
69
-
70
-
71
-
72
- }
91
+ }
@@ -1,28 +1,28 @@
1
- import {
2
- Body,
3
- Controller,
4
- HttpStatus,
5
- Inject,
6
- Post,
7
- Res,
8
- ValidationPipe,
9
- } from '@nestjs/common';
10
- import { UserService } from '../service/user.service';
11
- import { CreateUserDto } from '../dto/create-user.dto';
12
- import { Response } from 'express';
13
-
14
- @Controller('user')
15
- export class UserController {
16
- constructor(
17
- @Inject('UserService') private readonly userService: UserService,
18
- ) {}
19
-
20
- @Post('signup')
21
- async signup(
22
- @Body(new ValidationPipe()) createUserDto: CreateUserDto,
23
- @Res() res: Response,
24
- ) {
25
- const result = await this.userService.createEntity(createUserDto, null);
26
- res.status(HttpStatus.OK).json(result);
27
- }
28
- }
1
+ import {
2
+ Body,
3
+ Controller,
4
+ HttpStatus,
5
+ Inject,
6
+ Post,
7
+ Res,
8
+ ValidationPipe,
9
+ } from '@nestjs/common';
10
+ import { UserService } from '../service/user.service';
11
+ import { CreateUserDto } from '../dto/create-user.dto';
12
+ import { Response } from 'express';
13
+
14
+ @Controller('user')
15
+ export class UserController {
16
+ constructor(
17
+ @Inject('UserService') private readonly userService: UserService,
18
+ ) {}
19
+
20
+ @Post('signup')
21
+ async signup(
22
+ @Body(new ValidationPipe()) createUserDto: CreateUserDto,
23
+ @Res() res: Response,
24
+ ) {
25
+ const result = await this.userService.createEntity(createUserDto, null);
26
+ res.status(HttpStatus.OK).json(result);
27
+ }
28
+ }
@@ -1,4 +1,4 @@
1
- import { PartialType } from '@nestjs/mapped-types';
2
- import { CreateUserDto } from './create-user.dto';
3
-
4
- export class UpdateUserDto extends PartialType(CreateUserDto) {}
1
+ import { PartialType } from '@nestjs/mapped-types';
2
+ import { CreateUserDto } from './create-user.dto';
3
+
4
+ export class UpdateUserDto extends PartialType(CreateUserDto) {}
@@ -1,21 +1,21 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_user_role_mapping' })
4
- export class UserRoleMapping {
5
- constructor(user_id: number, role_id: number) {
6
- this.user_id = user_id;
7
- this.role_id = role_id;
8
- }
9
-
10
- @PrimaryGeneratedColumn()
11
- id: number;
12
-
13
- @Column({ type: 'bigint', nullable: true })
14
- user_id: number;
15
-
16
- @Column({ type: 'bigint', nullable: true })
17
- role_id: number;
18
-
19
- @Column({ type: 'int', nullable: true })
20
- is_default: number;
21
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_user_role_mapping' })
4
+ export class UserRoleMapping {
5
+ constructor(user_id: number, role_id: number) {
6
+ this.user_id = user_id;
7
+ this.role_id = role_id;
8
+ }
9
+
10
+ @PrimaryGeneratedColumn()
11
+ id: number;
12
+
13
+ @Column({ type: 'bigint', nullable: true })
14
+ user_id: number;
15
+
16
+ @Column({ type: 'bigint', nullable: true })
17
+ role_id: number;
18
+
19
+ @Column({ type: 'int', nullable: true })
20
+ is_default: number;
21
+ }
@@ -1,61 +1,61 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
-
3
- @Entity({ name: 'cr_user_session' })
4
- export class UserSession {
5
- @PrimaryGeneratedColumn()
6
- id: number;
7
-
8
- @Column({
9
- name: 'is_session_loggedout',
10
- nullable: true,
11
- type: 'int',
12
- })
13
- is_session_loggedout: number;
14
-
15
- @Column({
16
- name: 'login_id',
17
- nullable: true,
18
- length: 50,
19
- })
20
- login_id: string;
21
-
22
- @Column({
23
- name: 'login_time',
24
- nullable: true,
25
- })
26
- login_time: Date;
27
-
28
- @Column({
29
- name: 'logout_time',
30
- nullable: true,
31
- })
32
- logout_time: Date;
33
-
34
- @Column({
35
- name: 'session_key',
36
- nullable: true,
37
- length: 100,
38
- })
39
- session_key: string;
40
-
41
- @Column({
42
- name: 'user_id',
43
- nullable: true,
44
- type: 'bigint',
45
- })
46
- user_id: number;
47
-
48
- @Column({
49
- name: 'access_token',
50
- nullable: true,
51
- type: 'varchar',
52
- length: 5000,
53
- })
54
- access_token: string;
55
-
56
- @Column({
57
- name: 'expiry_date',
58
- nullable: true,
59
- })
60
- expiry_date: Date;
61
- }
1
+ import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity({ name: 'cr_user_session' })
4
+ export class UserSession {
5
+ @PrimaryGeneratedColumn()
6
+ id: number;
7
+
8
+ @Column({
9
+ name: 'is_session_loggedout',
10
+ nullable: true,
11
+ type: 'int',
12
+ })
13
+ is_session_loggedout: number;
14
+
15
+ @Column({
16
+ name: 'login_id',
17
+ nullable: true,
18
+ length: 50,
19
+ })
20
+ login_id: string;
21
+
22
+ @Column({
23
+ name: 'login_time',
24
+ nullable: true,
25
+ })
26
+ login_time: Date;
27
+
28
+ @Column({
29
+ name: 'logout_time',
30
+ nullable: true,
31
+ })
32
+ logout_time: Date;
33
+
34
+ @Column({
35
+ name: 'session_key',
36
+ nullable: true,
37
+ length: 100,
38
+ })
39
+ session_key: string;
40
+
41
+ @Column({
42
+ name: 'user_id',
43
+ nullable: true,
44
+ type: 'bigint',
45
+ })
46
+ user_id: number;
47
+
48
+ @Column({
49
+ name: 'access_token',
50
+ nullable: true,
51
+ type: 'varchar',
52
+ length: 5000,
53
+ })
54
+ access_token: string;
55
+
56
+ @Column({
57
+ name: 'expiry_date',
58
+ nullable: true,
59
+ })
60
+ expiry_date: Date;
61
+ }
@@ -1,33 +1,33 @@
1
- import { Repository } from 'typeorm';
2
- import { UserSession } from '../entity/user-session.entity';
3
- import { Injectable } from '@nestjs/common';
4
- import { InjectRepository } from '@nestjs/typeorm';
5
-
6
- @Injectable()
7
- export class UserSessionRepository {
8
- constructor(
9
- @InjectRepository(UserSession)
10
- private userSessionRepo: Repository<UserSession>,
11
- ) {}
12
-
13
- async findBySessionKey(sessionKey: string): Promise<UserSession | null> {
14
- return this.userSessionRepo.findOne({ where: { session_key: sessionKey } });
15
- }
16
-
17
- async findActiveSessionByUserId(userId: number): Promise<UserSession | null> {
18
- return this.userSessionRepo.findOne({
19
- where: { user_id: userId, is_session_loggedout: 0 },
20
- });
21
- }
22
-
23
- async saveSession(session: UserSession): Promise<UserSession> {
24
- return this.userSessionRepo.save(session);
25
- }
26
-
27
- async logoutSession(sessionKey: string): Promise<void> {
28
- await this.userSessionRepo.update(
29
- { session_key: sessionKey },
30
- { is_session_loggedout: 1, logout_time: new Date() },
31
- );
32
- }
33
- }
1
+ import { Repository } from 'typeorm';
2
+ import { UserSession } from '../entity/user-session.entity';
3
+ import { Injectable } from '@nestjs/common';
4
+ import { InjectRepository } from '@nestjs/typeorm';
5
+
6
+ @Injectable()
7
+ export class UserSessionRepository {
8
+ constructor(
9
+ @InjectRepository(UserSession)
10
+ private userSessionRepo: Repository<UserSession>,
11
+ ) {}
12
+
13
+ async findBySessionKey(sessionKey: string): Promise<UserSession | null> {
14
+ return this.userSessionRepo.findOne({ where: { session_key: sessionKey } });
15
+ }
16
+
17
+ async findActiveSessionByUserId(userId: number): Promise<UserSession | null> {
18
+ return this.userSessionRepo.findOne({
19
+ where: { user_id: userId, is_session_loggedout: 0 },
20
+ });
21
+ }
22
+
23
+ async saveSession(session: UserSession): Promise<UserSession> {
24
+ return this.userSessionRepo.save(session);
25
+ }
26
+
27
+ async logoutSession(sessionKey: string): Promise<void> {
28
+ await this.userSessionRepo.update(
29
+ { session_key: sessionKey },
30
+ { is_session_loggedout: 1, logout_time: new Date() },
31
+ );
32
+ }
33
+ }
@@ -15,7 +15,7 @@ VERIFY_OTP: "false"
15
15
  DEFAULT_OTP: "123456"
16
16
  AWS:
17
17
  S3:
18
- AWS_ACCESS_KEY_ID: "AKIAYYKIBDDSVJMYCJUV"
19
- AWS_SECRET_KEY: "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"
18
+ AWS_ACCESS_KEY_ID: "AKIAYYKIBDDSQF3KILGE"
19
+ AWS_SECRET_KEY: "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"
20
20
  AWS_REGION: "ap-south-1"
21
21
  BUCKET_NAME: "testether"