rez_core 1.0.26 → 1.0.27

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 (136) 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/dist/app.module.d.ts +0 -0
  9. package/dist/app.module.js +1 -0
  10. package/dist/app.module.js.map +1 -0
  11. package/dist/config/database.config.d.ts +3 -0
  12. package/dist/config/database.config.js +14 -6
  13. package/dist/config/database.config.js.map +1 -1
  14. package/dist/constant/global.constant.d.ts +6 -2
  15. package/dist/constant/global.constant.js +7 -3
  16. package/dist/constant/global.constant.js.map +1 -1
  17. package/dist/main.js +2 -1
  18. package/dist/main.js.map +1 -1
  19. package/dist/module/auth/auth.module.js +1 -1
  20. package/dist/module/auth/auth.module.js.map +1 -1
  21. package/dist/module/auth/guards/role.guard.js +3 -3
  22. package/dist/module/auth/strategies/google.strategy.d.ts +3 -1
  23. package/dist/module/auth/strategies/google.strategy.js +7 -5
  24. package/dist/module/auth/strategies/google.strategy.js.map +1 -1
  25. package/dist/module/auth/strategies/jwt.strategy.d.ts +4 -4
  26. package/dist/module/auth/strategies/jwt.strategy.js +8 -9
  27. package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
  28. package/dist/module/meta/entity/base-entity.entity.d.ts +1 -2
  29. package/dist/module/meta/entity/base-entity.entity.js +1 -2
  30. package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
  31. package/dist/module/meta/entity/entity-master.entity.d.ts +1 -0
  32. package/dist/module/meta/entity/entity-master.entity.js +4 -0
  33. package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
  34. package/dist/module/meta/entity/media-data.entity.d.ts +11 -0
  35. package/dist/module/meta/entity/media-data.entity.js +55 -0
  36. package/dist/module/meta/entity/media-data.entity.js.map +1 -0
  37. package/dist/module/meta/entity.module.js +8 -1
  38. package/dist/module/meta/entity.module.js.map +1 -1
  39. package/dist/module/meta/repository/media-data.repository.d.ts +9 -0
  40. package/dist/module/meta/repository/media-data.repository.js +55 -0
  41. package/dist/module/meta/repository/media-data.repository.js.map +1 -0
  42. package/dist/module/meta/service/entity-list.service.d.ts +1 -0
  43. package/dist/module/meta/service/entity-list.service.js +14 -2
  44. package/dist/module/meta/service/entity-list.service.js.map +1 -1
  45. package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
  46. package/dist/module/meta/service/entity-service-impl.service.js +21 -4
  47. package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
  48. package/dist/module/meta/service/media-data.service.d.ts +9 -0
  49. package/dist/module/meta/service/media-data.service.js +36 -0
  50. package/dist/module/meta/service/media-data.service.js.map +1 -0
  51. package/dist/module/module/entity/menu.entity.d.ts +1 -2
  52. package/dist/module/module/entity/menu.entity.js +1 -2
  53. package/dist/module/module/entity/menu.entity.js.map +1 -1
  54. package/dist/module/module/entity/module.entity.d.ts +1 -2
  55. package/dist/module/module/entity/module.entity.js +1 -2
  56. package/dist/module/module/entity/module.entity.js.map +1 -1
  57. package/dist/module/notification/controller/otp.controller.d.ts +5 -3
  58. package/dist/module/notification/controller/otp.controller.js +7 -4
  59. package/dist/module/notification/controller/otp.controller.js.map +1 -1
  60. package/dist/module/notification/service/otp.service.d.ts +5 -3
  61. package/dist/module/notification/service/otp.service.js +7 -4
  62. package/dist/module/notification/service/otp.service.js.map +1 -1
  63. package/dist/module/user/service/login.service.d.ts +3 -1
  64. package/dist/module/user/service/login.service.js +7 -5
  65. package/dist/module/user/service/login.service.js.map +1 -1
  66. package/dist/module/user/service/user.service.d.ts +5 -3
  67. package/dist/module/user/service/user.service.js +10 -6
  68. package/dist/module/user/service/user.service.js.map +1 -1
  69. package/dist/resources/dev.properties.yaml +15 -0
  70. package/dist/resources/properties.module.d.ts +2 -0
  71. package/dist/resources/properties.module.js +25 -0
  72. package/dist/resources/properties.module.js.map +1 -0
  73. package/dist/resources/properties.yaml.d.ts +2 -0
  74. package/dist/resources/properties.yaml.js +10 -0
  75. package/dist/resources/properties.yaml.js.map +1 -0
  76. package/dist/resources/uat.properties.yaml +15 -0
  77. package/dist/tsconfig.build.tsbuildinfo +1 -1
  78. package/nest-cli.json +6 -0
  79. package/package.json +1 -1
  80. package/src/app.module.ts +0 -0
  81. package/src/config/database.config.ts +10 -5
  82. package/src/constant/global.constant.ts +13 -4
  83. package/src/module/auth/auth.module.ts +3 -2
  84. package/src/module/auth/guards/jwt.guard.ts +22 -22
  85. package/src/module/auth/guards/role.guard.ts +68 -68
  86. package/src/module/auth/services/auth.service.ts +29 -29
  87. package/src/module/auth/services/jwt.service.ts +11 -11
  88. package/src/module/auth/strategies/google.strategy.ts +7 -4
  89. package/src/module/auth/strategies/jwt.strategy.ts +5 -6
  90. package/src/module/auth/strategies/local.strategy.ts +13 -13
  91. package/src/module/dev/dev.module.ts +12 -12
  92. package/src/module/dev/service/dev.service.ts +7 -7
  93. package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
  94. package/src/module/enterprise/entity/organization.entity.ts +80 -80
  95. package/src/module/master/controller/master.controller.ts +22 -22
  96. package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
  97. package/src/module/meta/entity/attribute-master.entity.ts +67 -67
  98. package/src/module/meta/entity/base-entity.entity.ts +1 -2
  99. package/src/module/meta/entity/entity-master.entity.ts +3 -0
  100. package/src/module/meta/entity/media-data.entity.ts +32 -0
  101. package/src/module/meta/entity/preference.entity.ts +65 -65
  102. package/src/module/meta/entity.module.ts +8 -1
  103. package/src/module/meta/repository/attribute-master.repository.ts +28 -28
  104. package/src/module/meta/repository/media-data.repository.ts +50 -0
  105. package/src/module/meta/repository/preference.repository.ts +20 -20
  106. package/src/module/meta/service/entity-list.service.ts +21 -2
  107. package/src/module/meta/service/entity-service-impl.service.ts +36 -11
  108. package/src/module/meta/service/media-data.service.ts +44 -0
  109. package/src/module/module/controller/menu.controller.ts +15 -15
  110. package/src/module/module/entity/menu.entity.ts +1 -2
  111. package/src/module/module/entity/module-access.entity.ts +22 -22
  112. package/src/module/module/entity/module-action.entity.ts +19 -19
  113. package/src/module/module/entity/module.entity.ts +1 -2
  114. package/src/module/notification/controller/otp.controller.ts +8 -3
  115. package/src/module/notification/service/otp.service.ts +6 -3
  116. package/src/module/user/controller/user.controller.ts +28 -28
  117. package/src/module/user/dto/update-user.dto.ts +4 -4
  118. package/src/module/user/entity/user-role-mapping.entity.ts +21 -21
  119. package/src/module/user/entity/user-session.entity.ts +61 -61
  120. package/src/module/user/entity/user.entity.ts +35 -35
  121. package/src/module/user/repository/role.repository.ts +16 -16
  122. package/src/module/user/repository/userSession.repository.ts +33 -33
  123. package/src/module/user/service/login.service.ts +7 -5
  124. package/src/module/user/service/user.service.ts +10 -7
  125. package/src/resources/dev.properties.yaml +15 -0
  126. package/src/resources/properties.module.ts +12 -0
  127. package/src/resources/properties.yaml.ts +11 -0
  128. package/src/resources/uat.properties.yaml +15 -0
  129. package/src/utils/service/encryptUtil.service.ts +97 -97
  130. package/src/utils/service/excelUtil.service.ts +15 -15
  131. package/src/utils/service/reflection-helper.service.ts +53 -53
  132. package/.env +0 -10
  133. package/dist/constant/status.constant.d.ts +0 -4
  134. package/dist/constant/status.constant.js +0 -9
  135. package/dist/constant/status.constant.js.map +0 -1
  136. package/src/constant/status.constant.ts +0 -3
@@ -0,0 +1,50 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { MediaData } from '../entity/media-data.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class MediaDataRepository {
8
+ constructor(
9
+ @InjectRepository(MediaData)
10
+ private readonly mediaRepository: Repository<MediaData>,
11
+ ) {}
12
+
13
+ async findByAttributeKeyAndMappedEntityIdAndMappedEntityType(
14
+ attributeKey: string,
15
+ mappedEntityId: number,
16
+ mappedEntityType: string,
17
+ ) {
18
+ return await this.mediaRepository.findOne({
19
+ where: {
20
+ mapped_attribute_key: attributeKey,
21
+ mapped_entity_id: mappedEntityId,
22
+ mapped_entity_type: mappedEntityType,
23
+ },
24
+ });
25
+ }
26
+
27
+ async findByMappedEntityIdAndMappedEntityType(
28
+ mappedEntityId: number,
29
+ mappedEntityType: string,
30
+ ) {
31
+ return await this.mediaRepository.find({
32
+ where: {
33
+ mapped_entity_id: mappedEntityId,
34
+ mapped_entity_type: mappedEntityType,
35
+ },
36
+ });
37
+ }
38
+
39
+ async deleteByAttributeKeyAndMappedEntityIdAndMappedEntityType(
40
+ attributeKey: string,
41
+ mappedEntityId: number,
42
+ mappedEntityType: string,
43
+ ) {
44
+ return await this.mediaRepository.delete({
45
+ mapped_attribute_key: attributeKey,
46
+ mapped_entity_id: mappedEntityId,
47
+ mapped_entity_type: mappedEntityType,
48
+ });
49
+ }
50
+ }
@@ -1,20 +1,20 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectRepository } from '@nestjs/typeorm';
3
- import { PreferenceMaster } from '../entity/preference.entity';
4
- import { Repository } from 'typeorm';
5
-
6
- @Injectable()
7
- export class PreferenceRepository {
8
- constructor(
9
- @InjectRepository(PreferenceMaster)
10
- private readonly preferenceRepository: Repository<PreferenceMaster>,
11
- ) {}
12
-
13
- async findByPreferenceKey(
14
- preferenceKey: string,
15
- ): Promise<PreferenceMaster | null> {
16
- return await this.preferenceRepository.findOne({
17
- where: { preference_key: preferenceKey },
18
- });
19
- }
20
- }
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { PreferenceMaster } from '../entity/preference.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class PreferenceRepository {
8
+ constructor(
9
+ @InjectRepository(PreferenceMaster)
10
+ private readonly preferenceRepository: Repository<PreferenceMaster>,
11
+ ) {}
12
+
13
+ async findByPreferenceKey(
14
+ preferenceKey: string,
15
+ ): Promise<PreferenceMaster | null> {
16
+ return await this.preferenceRepository.findOne({
17
+ where: { preference_key: preferenceKey },
18
+ });
19
+ }
20
+ }
@@ -97,10 +97,10 @@ export class EntityListService {
97
97
  private getQuery(source: string, groupByColumn: string | null) {
98
98
  if (groupByColumn) {
99
99
  return `SELECT ${groupByColumn} as tab_value, COUNT(1) AS tab_value_count
100
- FROM ${source}`;
100
+ FROM ${source}`;
101
101
  } else {
102
102
  return `SELECT *
103
- FROM ${source}`;
103
+ FROM ${source}`;
104
104
  }
105
105
  }
106
106
 
@@ -145,4 +145,23 @@ export class EntityListService {
145
145
 
146
146
  return { query, argumentList: argsObjectList };
147
147
  }
148
+
149
+ public async getMaxSequenceNumber(
150
+ tableName: string,
151
+ parentType: string,
152
+ parentId: number,
153
+ ) {
154
+ let query = `SELECT COUNT(1) seq_no
155
+ FROM ${tableName} `;
156
+ const argsObjectList: any[] = [];
157
+ if (parentId) {
158
+ query += `parent_id = ? AND parent_type = ? `;
159
+ argsObjectList.push(parentId);
160
+ argsObjectList.push(parentType);
161
+ }
162
+
163
+ let result = await this.entityManager.query(query, argsObjectList);
164
+
165
+ return result ? result[0].seq_no : 0;
166
+ }
148
167
  }
@@ -1,5 +1,5 @@
1
1
  import { EntityService } from './entity.service';
2
- import { Inject, Injectable } from '@nestjs/common';
2
+ import { BadRequestException, Inject, Injectable } from '@nestjs/common';
3
3
  import { UserData } from '../../user/entity/user.entity';
4
4
  import { EntityMasterService } from './entity-master.service';
5
5
  import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
@@ -15,6 +15,7 @@ import { ExcelHelper } from '../../../utils/service/excel-helper.service';
15
15
  import { ExcelsheetData } from '../../../utils/dto/excelsheet-data.dto';
16
16
  import { EntityTableService } from './entity-table.service';
17
17
  import { EntityTableColumnService } from './entity-table-column.service';
18
+ import { ENTITYTYPE_ENTITYMASTER } from '../../../constant/global.constant';
18
19
 
19
20
  @Injectable()
20
21
  export class EntityServiceImpl implements EntityService<BaseEntity> {
@@ -26,13 +27,14 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
26
27
  @Inject() protected readonly entityListService: EntityListService;
27
28
  @Inject() protected readonly loggingService: LoggingService;
28
29
 
29
- constructor() {}
30
-
31
30
  async createEntity(
32
31
  entityData: BaseEntity,
33
32
  loggedInUser: UserData | null,
34
33
  manager?: EntityManager,
35
34
  ): Promise<BaseEntity> {
35
+ if (!entityData.entity_type) {
36
+ throw new BadRequestException(`EntityType is missing`);
37
+ }
36
38
  const entityMaster = await this.entityMasterService.getEntityData(
37
39
  entityData.entity_type,
38
40
  );
@@ -46,7 +48,17 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
46
48
  `Repository service not found for entityType: ${entityData.entity_type}`,
47
49
  );
48
50
  }
49
- entityData.entity_type = entityMaster.mappedEntityType;
51
+
52
+ if (!entityData.code) {
53
+ let maxSeqNo = await this.getMaxSequenceNumber(
54
+ entityData.entity_type,
55
+ entityData.parent_id,
56
+ entityData.parent_type,
57
+ );
58
+ maxSeqNo = Number(maxSeqNo) + 1;
59
+ entityData.code = entityData.entity_type + maxSeqNo;
60
+ }
61
+
50
62
  entityData.created_date = new Date();
51
63
  if (loggedInUser) {
52
64
  entityData.created_by = loggedInUser.id;
@@ -86,13 +98,6 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
86
98
  id: number,
87
99
  ): Promise<BaseEntity | null> {
88
100
  const entityData = await this.entityMasterService.getEntityData(entityType);
89
- // this.loggingService.log(
90
- // 'info',
91
- // EntityServiceImpl.name,
92
- // 'GetEntity',
93
- // 'STARTED',
94
- // [{ entityData }],
95
- // );
96
101
 
97
102
  const repoService = this.reflectionHelper.getRepoService(
98
103
  entityData.entityDataClass,
@@ -244,4 +249,24 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
244
249
  excelData.addSheet(sheet);
245
250
  }
246
251
  }
252
+
253
+ private async getMaxSequenceNumber(
254
+ entityType: string,
255
+ parentId: number,
256
+ parentType: string,
257
+ ): Promise<number> {
258
+ let tableName: string;
259
+ if (ENTITYTYPE_ENTITYMASTER === entityType) {
260
+ tableName = 'cr_entity_master';
261
+ } else {
262
+ let entityMaster =
263
+ await this.entityMasterService.getEntityData(entityType);
264
+ tableName = entityMaster.dbTableName;
265
+ }
266
+ return await this.entityListService.getMaxSequenceNumber(
267
+ tableName,
268
+ parentType,
269
+ parentId,
270
+ );
271
+ }
247
272
  }
@@ -0,0 +1,44 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from './entity-service-impl.service';
3
+ import { MediaDataRepository } from '../repository/media-data.repository';
4
+
5
+ @Injectable()
6
+ export class MediaDataService extends EntityServiceImpl {
7
+ constructor(private readonly mediaRepository: MediaDataRepository) {
8
+ super();
9
+ }
10
+
11
+ async findByAttributeKeyAndMappedEntityIdAndMappedEntityType(
12
+ attributeKey: string,
13
+ mappedEntityId: number,
14
+ mappedEntityType: string,
15
+ ) {
16
+ return await this.mediaRepository.findByAttributeKeyAndMappedEntityIdAndMappedEntityType(
17
+ attributeKey,
18
+ mappedEntityId,
19
+ mappedEntityType,
20
+ );
21
+ }
22
+
23
+ async findByMappedEntityIdAndMappedEntityType(
24
+ mappedEntityId: number,
25
+ mappedEntityType: string,
26
+ ) {
27
+ return await this.mediaRepository.findByMappedEntityIdAndMappedEntityType(
28
+ mappedEntityId,
29
+ mappedEntityType,
30
+ );
31
+ }
32
+
33
+ async deleteByAttributeKeyAndMappedEntityIdAndMappedEntityType(
34
+ attributeKey: string,
35
+ mappedEntityId: number,
36
+ mappedEntityType: string,
37
+ ) {
38
+ return await this.mediaRepository.deleteByAttributeKeyAndMappedEntityIdAndMappedEntityType(
39
+ attributeKey,
40
+ mappedEntityId,
41
+ mappedEntityType,
42
+ );
43
+ }
44
+ }
@@ -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,5 +1,4 @@
1
1
  import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
- import { StatusType } from '../../../constant/status.constant';
3
2
 
4
3
  @Entity({ name: 'cr_menu' })
5
4
  export class MenuData {
@@ -13,7 +12,7 @@ export class MenuData {
13
12
  module_code: string;
14
13
 
15
14
  @Column({ type: 'varchar', length: 100, nullable: true })
16
- status: StatusType;
15
+ status: string;
17
16
 
18
17
  @Column({ type: 'varchar', length: 100, nullable: true })
19
18
  wbs_code: string;
@@ -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,5 +1,4 @@
1
1
  import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
- import { StatusType } from '../../../constant/status.constant';
3
2
 
4
3
  @Entity({ name: 'cr_module' })
5
4
  export class ModuleData {
@@ -16,7 +15,7 @@ export class ModuleData {
16
15
  wbs_code: string;
17
16
 
18
17
  @Column({ type: 'varchar', length: 100, nullable: true })
19
- status: StatusType;
18
+ status: string;
20
19
 
21
20
  @Column({ type: 'varchar', length: 100, nullable: true })
22
21
  module_level: string;
@@ -1,12 +1,17 @@
1
1
  import { BadRequestException, Body, Controller, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
2
2
  import { OtpService } from '../service/otp.service';
3
+ import { ConfigService } from '@nestjs/config';
3
4
 
4
5
  @Controller('otp')
5
6
  export class OtpController{
6
- otpExpiry = process.env.otp_expiry || '2';
7
- otpLength = process.env.otp_length || '6';
8
- constructor(private readonly otpService: OtpService) {
7
+
8
+ constructor(private readonly otpService: OtpService,
9
+ private configService: ConfigService,
10
+ ) {
9
11
  }
12
+
13
+ otpExpiry = this.configService.get('OTP_EXPIRY')|| '2';
14
+ otpLength = this.configService.get('OTP_LENGTH')|| '6';
10
15
 
11
16
  @Post('generate')
12
17
  @HttpCode(HttpStatus.OK)
@@ -2,17 +2,20 @@ import { Injectable } from '@nestjs/common';
2
2
  import { OtpRepository } from '../repository/otp.repository';
3
3
  import { Otp } from '../entity/otp.entity';
4
4
  import { ClockIDGenService } from '../../../utils/service/clockIDGenUtil.service';
5
+ import { ConfigService } from '@nestjs/config';
5
6
 
6
7
  @Injectable()
7
8
  export class OtpService {
8
- VERIFY_OTP = process.env.VERIFY_OTP || 'true';
9
- DEFAULT_OTP = process.env.DEFAULT_OTP || '123456';
10
-
11
9
  constructor(
12
10
  private readonly otpRepository: OtpRepository,
13
11
  private readonly idGen: ClockIDGenService,
12
+ private configService: ConfigService,
14
13
  ) {
15
14
  }
15
+
16
+ VERIFY_OTP = this.configService.get('VERIFY_OTP') || 'true';
17
+ DEFAULT_OTP = this.configService.get('DEFAULT_OTP') || '123456';
18
+
16
19
 
17
20
  async generate(identifier: string, service: string, expiresIn: number = 5, otpLength: number = 6) {
18
21
  let otp = new Otp();
@@ -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
+ }