rez_core 0.0.1 → 0.0.2

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 (89) hide show
  1. package/data/master.xlsx +0 -0
  2. package/dist/config/database.config.js +2 -2
  3. package/dist/config/database.config.js.map +1 -1
  4. package/dist/constant/global.constant.d.ts +1 -1
  5. package/dist/constant/global.constant.js +1 -1
  6. package/dist/module/enterprise/service/organization.service.d.ts +11 -0
  7. package/dist/module/enterprise/service/organization.service.js +48 -0
  8. package/dist/module/enterprise/service/organization.service.js.map +1 -0
  9. package/dist/module/meta/controller/entity.controller.d.ts +1 -0
  10. package/dist/module/meta/controller/entity.controller.js +20 -1
  11. package/dist/module/meta/controller/entity.controller.js.map +1 -1
  12. package/dist/module/meta/entity/entity-master.entity.js +1 -2
  13. package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
  14. package/dist/module/meta/entity/entity-table-column.entity.d.ts +15 -0
  15. package/dist/module/meta/entity/entity-table-column.entity.js +70 -0
  16. package/dist/module/meta/entity/entity-table-column.entity.js.map +1 -1
  17. package/dist/module/meta/entity/entity-table.entity.d.ts +17 -0
  18. package/dist/module/meta/entity/entity-table.entity.js +78 -0
  19. package/dist/module/meta/entity/entity-table.entity.js.map +1 -1
  20. package/dist/module/meta/entity.module.js +20 -2
  21. package/dist/module/meta/entity.module.js.map +1 -1
  22. package/dist/module/meta/service/entity-service-impl.service.d.ts +6 -2
  23. package/dist/module/meta/service/entity-service-impl.service.js +7 -1
  24. package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
  25. package/dist/module/meta/service/entity.service.d.ts +2 -0
  26. package/dist/module/meta/service/preference.service.d.ts +2 -1
  27. package/dist/module/meta/service/preference.service.js +4 -2
  28. package/dist/module/meta/service/preference.service.js.map +1 -1
  29. package/dist/module/module/controller/module-access.controller.d.ts +20 -4
  30. package/dist/module/module/controller/module-access.controller.js +40 -11
  31. package/dist/module/module/controller/module-access.controller.js.map +1 -1
  32. package/dist/module/module/entity/module.entity.d.ts +1 -0
  33. package/dist/module/module/entity/module.entity.js +4 -0
  34. package/dist/module/module/entity/module.entity.js.map +1 -1
  35. package/dist/module/module/repository/module-access.repository.d.ts +25 -7
  36. package/dist/module/module/repository/module-access.repository.js +64 -21
  37. package/dist/module/module/repository/module-access.repository.js.map +1 -1
  38. package/dist/module/module/service/module-access.service.d.ts +20 -4
  39. package/dist/module/module/service/module-access.service.js +12 -3
  40. package/dist/module/module/service/module-access.service.js.map +1 -1
  41. package/dist/module/user/entity/role.entity.js +1 -1
  42. package/dist/module/user/entity/role.entity.js.map +1 -1
  43. package/dist/module/user/service/role.service.d.ts +2 -1
  44. package/dist/module/user/service/role.service.js +4 -2
  45. package/dist/module/user/service/role.service.js.map +1 -1
  46. package/dist/module/user/service/user-session.service.d.ts +3 -1
  47. package/dist/module/user/service/user-session.service.js +5 -3
  48. package/dist/module/user/service/user-session.service.js.map +1 -1
  49. package/dist/module/user/service/user.service.d.ts +4 -1
  50. package/dist/module/user/service/user.service.js +11 -5
  51. package/dist/module/user/service/user.service.js.map +1 -1
  52. package/dist/module/user/user.module.js +2 -2
  53. package/dist/module/user/user.module.js.map +1 -1
  54. package/dist/tsconfig.build.tsbuildinfo +1 -1
  55. package/dist/utils/service/clockIDGenUtil.service.d.ts +6 -6
  56. package/dist/utils/service/clockIDGenUtil.service.js +11 -10
  57. package/dist/utils/service/clockIDGenUtil.service.js.map +1 -1
  58. package/dist/utils/utils.module.js +3 -4
  59. package/dist/utils/utils.module.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/config/database.config.ts +2 -2
  62. package/src/constant/global.constant.ts +1 -1
  63. package/src/module/enterprise/service/organization.service.ts +34 -0
  64. package/src/module/meta/controller/entity.controller.ts +24 -5
  65. package/src/module/meta/dto/entity-list-data.dto.ts +6 -0
  66. package/src/module/meta/dto/entity-tab.dto.ts +4 -0
  67. package/src/module/meta/entity/entity-master.entity.ts +1 -2
  68. package/src/module/meta/entity/entity-table-column.entity.ts +44 -0
  69. package/src/module/meta/entity/entity-table.entity.ts +51 -0
  70. package/src/module/meta/entity.module.ts +20 -2
  71. package/src/module/meta/repository/entity-table-column.repository.ts +21 -0
  72. package/src/module/meta/repository/entity-table.repository.ts +18 -0
  73. package/src/module/meta/service/entity-list.service.ts +138 -0
  74. package/src/module/meta/service/entity-service-impl.service.ts +25 -2
  75. package/src/module/meta/service/entity-table-column.service.ts +18 -0
  76. package/src/module/meta/service/entity-table.service.ts +11 -0
  77. package/src/module/meta/service/entity.service.ts +11 -0
  78. package/src/module/meta/service/preference.service.ts +8 -1
  79. package/src/module/module/controller/module-access.controller.ts +23 -9
  80. package/src/module/module/entity/module.entity.ts +3 -0
  81. package/src/module/module/repository/module-access.repository.ts +86 -24
  82. package/src/module/module/service/module-access.service.ts +16 -4
  83. package/src/module/user/entity/role.entity.ts +1 -1
  84. package/src/module/user/service/role.service.ts +3 -1
  85. package/src/module/user/service/user-session.service.ts +2 -1
  86. package/src/module/user/service/user.service.ts +16 -7
  87. package/src/module/user/user.module.ts +3 -2
  88. package/src/utils/service/clockIDGenUtil.service.ts +10 -12
  89. package/src/utils/utils.module.ts +7 -9
@@ -1,8 +1,8 @@
1
1
  export declare class ClockIDGenService {
2
- static _counter: bigint;
3
- static timestampBits: number;
4
- static timestampMask: bigint;
5
- static counterBits: number;
6
- static counterMask: bigint;
7
- static idGenerator(prefix?: string): string;
2
+ private _counter;
3
+ private timestampBits;
4
+ private timestampMask;
5
+ private counterBits;
6
+ private counterMask;
7
+ idGenerator(prefix?: string): string;
8
8
  }
@@ -5,27 +5,28 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var ClockIDGenService_1;
9
8
  Object.defineProperty(exports, "__esModule", { value: true });
10
9
  exports.ClockIDGenService = void 0;
11
10
  const common_1 = require("@nestjs/common");
12
- let ClockIDGenService = ClockIDGenService_1 = class ClockIDGenService {
13
- static idGenerator(prefix) {
11
+ let ClockIDGenService = class ClockIDGenService {
12
+ constructor() {
13
+ this._counter = 0n;
14
+ this.timestampBits = 42;
15
+ this.timestampMask = BigInt(Math.floor(Math.pow(2, this.timestampBits)) - 1);
16
+ this.counterBits = 10;
17
+ this.counterMask = BigInt(Math.floor(Math.pow(2, this.counterBits)) - 1);
18
+ }
19
+ idGenerator(prefix) {
14
20
  const timestamp = BigInt(Date.now()) & this.timestampMask;
15
21
  const counter = BigInt(this._counter++) & this.counterMask;
16
22
  let now = timestamp << BigInt(this.counterBits);
17
23
  now = now | counter;
18
24
  const id = now.toString(36).toUpperCase();
19
- return prefix + id;
25
+ return prefix ? prefix + id : id;
20
26
  }
21
27
  };
22
28
  exports.ClockIDGenService = ClockIDGenService;
23
- ClockIDGenService._counter = 0n;
24
- ClockIDGenService.timestampBits = 42;
25
- ClockIDGenService.timestampMask = BigInt(Math.floor(Math.pow(2, ClockIDGenService_1.timestampBits)) - 1);
26
- ClockIDGenService.counterBits = 10;
27
- ClockIDGenService.counterMask = BigInt(Math.floor(Math.pow(2, ClockIDGenService_1.counterBits)) - 1);
28
- exports.ClockIDGenService = ClockIDGenService = ClockIDGenService_1 = __decorate([
29
+ exports.ClockIDGenService = ClockIDGenService = __decorate([
29
30
  (0, common_1.Injectable)()
30
31
  ], ClockIDGenService);
31
32
  //# sourceMappingURL=clockIDGenUtil.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clockIDGenUtil.service.js","sourceRoot":"","sources":["../../../src/utils/service/clockIDGenUtil.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAQ1B,MAAM,CAAC,WAAW,CAAC,MAAe;QAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3D,IAAI,GAAG,GAAG,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC/C,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC;QACpB,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,OAAO,MAAM,GAAG,EAAE,CAAC;IACvB,CAAC;;AAfQ,8CAAiB;AAEnB,0BAAQ,GAAG,EAAE,AAAL,CAAM;AACd,+BAAa,GAAG,EAAE,AAAL,CAAM;AACnB,+BAAa,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAiB,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,AAAvE,CAAwE;AACrF,6BAAW,GAAG,EAAE,AAAL,CAAM;AACjB,6BAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAiB,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,AAArE,CAAsE;4BAN/E,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAiB7B"}
1
+ {"version":3,"file":"clockIDGenUtil.service.js","sourceRoot":"","sources":["../../../src/utils/service/clockIDGenUtil.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACK,aAAQ,GAAG,EAAE,CAAC;QACd,kBAAa,GAAG,EAAE,CAAC;QACnB,kBAAa,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,gBAAW,GAAG,EAAE,CAAC;QACjB,gBAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAUhF,CAAC;IARG,WAAW,CAAC,MAAe;QACvB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3D,IAAI,GAAG,GAAG,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC;QACpB,MAAM,EAAE,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrC,CAAC;CACJ,CAAA;AAfY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAe7B"}
@@ -8,19 +8,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.UtilsModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
- const typeorm_1 = require("@nestjs/typeorm");
12
11
  const loggingUtil_service_1 = require("./service/loggingUtil.service");
13
12
  const reflection_helper_service_1 = require("./service/reflection-helper.service");
14
13
  const excelUtil_service_1 = require("./service/excelUtil.service");
14
+ const clockIDGenUtil_service_1 = require("./service/clockIDGenUtil.service");
15
15
  let UtilsModule = class UtilsModule {
16
16
  };
17
17
  exports.UtilsModule = UtilsModule;
18
18
  exports.UtilsModule = UtilsModule = __decorate([
19
19
  (0, common_1.Global)(),
20
20
  (0, common_1.Module)({
21
- imports: [typeorm_1.TypeOrmModule.forFeature([])],
22
- providers: [loggingUtil_service_1.LoggingService, reflection_helper_service_1.ReflectionHelper, excelUtil_service_1.ExcelUtil],
23
- exports: [loggingUtil_service_1.LoggingService, reflection_helper_service_1.ReflectionHelper, excelUtil_service_1.ExcelUtil],
21
+ providers: [loggingUtil_service_1.LoggingService, reflection_helper_service_1.ReflectionHelper, excelUtil_service_1.ExcelUtil, clockIDGenUtil_service_1.ClockIDGenService],
22
+ exports: [loggingUtil_service_1.LoggingService, reflection_helper_service_1.ReflectionHelper, excelUtil_service_1.ExcelUtil, clockIDGenUtil_service_1.ClockIDGenService],
24
23
  })
25
24
  ], UtilsModule);
26
25
  //# sourceMappingURL=utils.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.module.js","sourceRoot":"","sources":["../../src/utils/utils.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,6CAAgD;AAEhD,uEAA+D;AAC/D,mFAAuE;AACvE,mEAAwD;AAQjD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IANvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACvC,SAAS,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAE,6BAAS,CAAC;QACxD,OAAO,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAE,6BAAS,CAAC;KACvD,CAAC;GACW,WAAW,CAAG"}
1
+ {"version":3,"file":"utils.module.js","sourceRoot":"","sources":["../../src/utils/utils.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8C;AAC9C,uEAA+D;AAC/D,mFAAqE;AACrE,mEAAwD;AACxD,6EAAqE;AAO9D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAC,6BAAS,EAAC,0CAAiB,CAAC;QACzE,OAAO,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAC,6BAAS,EAAC,0CAAiB,CAAC;KACxE,CAAC;GACW,WAAW,CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -7,10 +7,10 @@ export class MySqlConfiguration implements TypeOrmOptionsFactory {
7
7
  createTypeOrmOptions(): TypeOrmModuleOptions {
8
8
  return {
9
9
  type: 'mysql',
10
- host: process.env.DB_HOST || 'localhost',
10
+ host: process.env.DB_HOST || '13.234.25.234',
11
11
  port: parseInt(process.env.DB_PORT || '3306', 10),
12
12
  username: process.env.DB_USER || 'root',
13
- password: process.env.DB_PASS || 'root',
13
+ password: process.env.DB_PASS || 'Rezolut@123',
14
14
  database: process.env.DB_NAME || 'core',
15
15
  entities: [__dirname + '/../module/**/*.entity.{ts,js}'],
16
16
  synchronize: true,
@@ -3,7 +3,7 @@ export const ENTITYTYPE_USER = 'USR';
3
3
  export const ENTITYTYPE_ENTITYMASTER = 'EMS';
4
4
  export const ENTITYTYPE_ROLE = 'ROL';
5
5
  export const ENTITYTYPE_ENTITYTABLE = 'ETB';
6
- export const ENTITYTYPE_ENTITYTABLECOLUMN = 'ETM';
6
+ export const ENTITYTYPE_ENTITYTABLECOLUMN = 'ETC';
7
7
  export const ENTITYTYPE_PREFERENCEMASTER = 'PRM'
8
8
  export const masterKey: string = process.env.master_key || '';
9
9
  export const masterIv: string = process.env.master_iv || '';
@@ -0,0 +1,34 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { Repository } from 'typeorm';
4
+ import { OrganizationData } from '../entity/organization.entity';
5
+
6
+ @Injectable()
7
+ export class OrganizationService {
8
+ constructor(
9
+ @InjectRepository(OrganizationData)
10
+ private readonly organizationRepository: Repository<OrganizationData>,
11
+ ) {}
12
+
13
+ async create(organizationDto: Partial<OrganizationData>): Promise<OrganizationData> {
14
+ const organization = this.organizationRepository.create(organizationDto);
15
+ return await this.organizationRepository.save(organization);
16
+ }
17
+
18
+ async findAll(): Promise<OrganizationData[]> {
19
+ return await this.organizationRepository.find();
20
+ }
21
+
22
+ async findOne(id: number): Promise<OrganizationData | null> {
23
+ return await this.organizationRepository.findOne({ where: { id } });
24
+ }
25
+
26
+ async update(id: number, organizationDto: Partial<OrganizationData>): Promise<OrganizationData | null> {
27
+ await this.organizationRepository.update(id, organizationDto);
28
+ return this.findOne(id);
29
+ }
30
+
31
+ async remove(id: number): Promise<void> {
32
+ await this.organizationRepository.delete(id);
33
+ }
34
+ }
@@ -37,12 +37,13 @@ export class EntityController {
37
37
  'Query parameter "entity_type" is required',
38
38
  );
39
39
  }
40
- const entityMaster = await this.entityMasterService.getEntityData(entityType);
40
+ const entityMaster =
41
+ await this.entityMasterService.getEntityData(entityType);
41
42
 
42
43
  const entityService =
43
- await this.reflectionHelper.getBean<EntityServiceImpl>(
44
- entityMaster.entityService,
45
- );
44
+ await this.reflectionHelper.getBean<EntityServiceImpl>(
45
+ entityMaster.entityService,
46
+ );
46
47
 
47
48
  if (entityService) {
48
49
  return await entityService.getEntityData(entityType, id);
@@ -70,7 +71,9 @@ export class EntityController {
70
71
  );
71
72
 
72
73
  if (entityService) {
73
- return res.status(HttpStatus.OK).json(await entityService.createEntity(entityData, null));
74
+ return res
75
+ .status(HttpStatus.OK)
76
+ .json(await entityService.createEntity(entityData, null));
74
77
  }
75
78
  }
76
79
 
@@ -105,4 +108,20 @@ export class EntityController {
105
108
  return response.status(HttpStatus.OK).json(entityData);
106
109
  }
107
110
  }
111
+
112
+ @Post('getFilteredDataWithTabs/:entity_type')
113
+ async getFilterDataWithTabs(
114
+ @Param('entity_type') entityType: string,
115
+ @Query('list_type') listType: string,
116
+ @Res() res: Response,
117
+ @Body() filters: Record<string, any> = {},
118
+ @Query('sort_column') sortColumn?: string,
119
+ @Query('sort_order') sortOrder?: string,
120
+ @Query('page') page: number = 0,
121
+ @Query('size') size: number = 1,
122
+ ) {
123
+
124
+ return res.status(HttpStatus.OK).json(await this.entityService.getFilterDataWithTabs(entityType, listType,
125
+ filters, sortColumn, sortOrder, page, size));
126
+ }
108
127
  }
@@ -0,0 +1,6 @@
1
+ import { EntityTab } from './entity-tab.dto';
2
+
3
+ export class EntityListData {
4
+ entity_list: any;
5
+ entity_tabs: EntityTab[];
6
+ }
@@ -0,0 +1,4 @@
1
+ export class EntityTab{
2
+ tab_value: string;
3
+ tab_value_count: number;
4
+ }
@@ -1,7 +1,6 @@
1
1
  import { BaseEntity } from './base-entity.entity';
2
2
  import { ENTITYTYPE_ENTITYMASTER } from '../../../constant/global.constant';
3
3
  import { Column, Entity } from 'typeorm';
4
- import { ApiProperty } from '@nestjs/swagger';
5
4
 
6
5
  @Entity({ name: 'cr_entity_master' })
7
6
  export class EntityMaster extends BaseEntity {
@@ -16,7 +15,7 @@ export class EntityMaster extends BaseEntity {
16
15
  length: 50,
17
16
  nullable: false,
18
17
  })
19
- @ApiProperty({ name: 'mapped_entity_type' })
18
+ @Column({ name: 'mapped_entity_type', nullable: true })
20
19
  mappedEntityType: string;
21
20
 
22
21
  @Column({ name: 'appcode', type: 'varchar', length: 50, nullable: true })
@@ -0,0 +1,44 @@
1
+ import { ENTITYTYPE_ENTITYTABLECOLUMN } from '../../../constant/global.constant';
2
+ import {Column, Entity} from 'typeorm';
3
+ import { BaseEntity } from './base-entity.entity';
4
+
5
+ @Entity({ name: 'cr_entity_table_column' })
6
+ export class EntityTableColumn extends BaseEntity {
7
+ constructor() {
8
+ super();
9
+ this.entity_type = ENTITYTYPE_ENTITYTABLECOLUMN;
10
+ }
11
+
12
+ @Column({ name: 'app_code', nullable: true })
13
+ app_code: string;
14
+
15
+ @Column({ name: 'mapped_entity_type', nullable: true })
16
+ mapped_entity_type: string;
17
+
18
+ @Column({ name: 'menu_code', nullable: true })
19
+ menu_code: string;
20
+
21
+ @Column({ name: 'table_name', nullable: true })
22
+ table_name: string;
23
+
24
+ @Column({ name: 'col_position', nullable: true })
25
+ col_position: number;
26
+
27
+ @Column({ name: 'sortable', nullable: true })
28
+ sortable: string;
29
+
30
+ @Column({ name: 'searchable', nullable: true })
31
+ searchable: string;
32
+
33
+ @Column({ name: 'attribute_key', nullable: true })
34
+ attribute_key: string;
35
+
36
+ @Column({ name: 'sort_type', nullable: true })
37
+ sort_type: string;
38
+
39
+ @Column({ name: 'data_type', nullable: true })
40
+ data_type: string;
41
+
42
+ @Column({ name: 'visible', nullable: true })
43
+ visible: string;
44
+ }
@@ -0,0 +1,51 @@
1
+ import { Column, Entity } from 'typeorm';
2
+ import { BaseEntity } from './base-entity.entity';
3
+ import {ENTITYTYPE_ENTITYTABLE} from "../../../constant/global.constant";
4
+
5
+ @Entity({ name: 'cr_entity_table' })
6
+ export class EntityTable extends BaseEntity {
7
+
8
+ constructor() {
9
+ super();
10
+ this.entity_type = ENTITYTYPE_ENTITYTABLE;
11
+ }
12
+
13
+ @Column({ name: 'app_code', nullable: true })
14
+ app_code: string;
15
+
16
+ @Column({ name: 'mapped_entity_type', nullable: true })
17
+ mapped_entity_type: string;
18
+
19
+ @Column({ name: 'menu_code', nullable: true })
20
+ menu_code: string;
21
+
22
+ @Column({ name: 'category', nullable: true })
23
+ category: string;
24
+
25
+ @Column({ name: 'is_default', nullable: true })
26
+ is_default: number;
27
+
28
+ @Column({ name: 'show_checkbox', nullable: true })
29
+ show_checkbox: number;
30
+
31
+ @Column({ name: 'show_row_count', nullable: true })
32
+ show_row_count: number;
33
+
34
+ @Column({ name: 'page_length', nullable: true })
35
+ page_length: number;
36
+
37
+ @Column({ name: 'row_reorder', nullable: true })
38
+ row_reorder: number;
39
+
40
+ @Column({ name: 'tab_column', nullable: true })
41
+ tab_column: string;
42
+
43
+ @Column({ name: 'list_type', nullable: true })
44
+ list_type: string;
45
+
46
+ @Column({ name: 'data_source', nullable: true })
47
+ data_source: string;
48
+
49
+ @Column({ name: 'is_proc', nullable: true })
50
+ is_proc: number;
51
+ }
@@ -12,10 +12,23 @@ import { PreferenceRepository } from './repository/preference.repository';
12
12
  import { PreferenceMaster } from './entity/preference.entity';
13
13
  import { MasterController } from '../master/controller/master.controller';
14
14
  import { MasterService } from '../master/service/master.service';
15
+ import { EntityTable } from './entity/entity-table.entity';
16
+ import { EntityTableColumn } from './entity/entity-table-column.entity';
17
+ import { EntityTableRepository } from './repository/entity-table.repository';
18
+ import { EntityTableService } from './service/entity-table.service';
19
+ import { EntityTableColumnRepository } from './repository/entity-table-column.repository';
20
+ import { EntityTableColumnService } from './service/entity-table-column.service';
21
+ import { EntityListService } from './service/entity-list.service';
15
22
 
16
23
  @Module({
17
24
  imports: [
18
- TypeOrmModule.forFeature([EntityMaster, AttributeMaster, PreferenceMaster]),
25
+ TypeOrmModule.forFeature([
26
+ EntityMaster,
27
+ AttributeMaster,
28
+ PreferenceMaster,
29
+ EntityTable,
30
+ EntityTableColumn,
31
+ ]),
19
32
  UtilsModule,
20
33
  ],
21
34
  providers: [
@@ -25,8 +38,13 @@ import { MasterService } from '../master/service/master.service';
25
38
  PreferenceService,
26
39
  PreferenceRepository,
27
40
  MasterService,
41
+ EntityTableRepository,
42
+ EntityTableService,
43
+ EntityTableColumnRepository,
44
+ EntityTableColumnService,
45
+ EntityListService,
28
46
  ],
29
- exports: [EntityMasterService, EntityServiceImpl, PreferenceService],
47
+ exports: [EntityMasterService, EntityServiceImpl, PreferenceService, EntityListService],
30
48
  controllers: [EntityController, MasterController],
31
49
  })
32
50
  export class EntityModule {}
@@ -0,0 +1,21 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { EntityTableColumn } from '../entity/entity-table-column.entity';
4
+ import { Repository } from 'typeorm';
5
+
6
+ @Injectable()
7
+ export class EntityTableColumnRepository {
8
+ constructor(
9
+ @InjectRepository(EntityTableColumn)
10
+ private entityTableColumnRepository: Repository<EntityTableColumn>,
11
+ ) {}
12
+
13
+ async findByParentIdAndParentType(parentId: number, parentType: string){
14
+ return await this.entityTableColumnRepository.find({
15
+ where: {
16
+ parent_id: parentId,
17
+ parent_type: parentType
18
+ }
19
+ });
20
+ }
21
+ }
@@ -0,0 +1,18 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { Repository } from 'typeorm';
4
+ import { EntityTable } from '../entity/entity-table.entity';
5
+
6
+ @Injectable()
7
+ export class EntityTableRepository {
8
+ constructor(
9
+ @InjectRepository(EntityTable)
10
+ private entityTableRepository: Repository<EntityTable>,
11
+ ) {}
12
+
13
+ async findByEntityTypeAndListType(entityType: string, listType: string) {
14
+ return await this.entityTableRepository.findOne({
15
+ where: { mapped_entity_type: entityType, list_type: listType },
16
+ });
17
+ }
18
+ }
@@ -0,0 +1,138 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityTableService } from './entity-table.service';
3
+ import { EntityListData } from '../dto/entity-list-data.dto';
4
+ import { EntityTable } from '../entity/entity-table.entity';
5
+ import { InjectEntityManager } from '@nestjs/typeorm';
6
+ import { EntityManager } from 'typeorm';
7
+ import { EntityTab } from '../dto/entity-tab.dto';
8
+ import { EntityTableColumnService } from './entity-table-column.service';
9
+
10
+ @Injectable()
11
+ export class EntityListService {
12
+ constructor(
13
+ private entityTableService: EntityTableService,
14
+ private entityTableColumnService: EntityTableColumnService,
15
+ @InjectEntityManager() private entityManager: EntityManager,
16
+ ) {}
17
+
18
+ async getFilterDataWithTabs(
19
+ entityType: string,
20
+ listType: string,
21
+ filters: Record<string, any>,
22
+ sortColumn: string | undefined,
23
+ sortOrder: string | undefined,
24
+ pageNumber: number,
25
+ pageSize: number,
26
+ ): Promise<EntityListData> {
27
+ let entityListData = new EntityListData();
28
+
29
+ let entityTable = await this.entityTableService.findByEntityTypeAndListType(
30
+ entityType,
31
+ listType,
32
+ );
33
+
34
+ if (entityTable) {
35
+ if (1 != entityTable.is_proc) {
36
+ let totalCount = await this.getTotalCount(entityTable, filters);
37
+ entityListData.entity_tabs = totalCount as EntityTab[];
38
+ entityListData.entity_list = await this.getFilteredList(
39
+ entityTable,
40
+ filters,
41
+ sortColumn,
42
+ sortOrder,
43
+ pageNumber,
44
+ pageSize,
45
+ );
46
+ }
47
+ }
48
+
49
+ return entityListData;
50
+ }
51
+
52
+ private async getFilteredList(
53
+ entityTable: EntityTable,
54
+ filters: Record<string, any>,
55
+ sortColumn: string | undefined,
56
+ sortOrder: string | undefined,
57
+ pageNumber: number,
58
+ pageSize: number,
59
+ ) {
60
+ let query = this.getQuery(entityTable.data_source, null);
61
+ let whereClause = await this.getWhereClause(entityTable, filters);
62
+ if (whereClause.query) {
63
+ query += whereClause.query;
64
+ }
65
+
66
+ if (sortColumn) query += ` ORDER BY ${sortColumn} ${sortOrder}`;
67
+
68
+ if (pageSize && pageNumber)
69
+ query += ` LIMIT ${pageSize} OFFSET ${pageNumber * pageSize}`;
70
+
71
+ return await this.entityManager.query(query, whereClause.argumentList);
72
+ }
73
+
74
+ private async getTotalCount(
75
+ entityTable: EntityTable,
76
+ filters: Record<string, any>,
77
+ ) {
78
+ let query = this.getQuery(entityTable.data_source, entityTable.tab_column);
79
+ let whereClause = await this.getWhereClause(entityTable, filters);
80
+ if (whereClause.query) {
81
+ query += whereClause.query;
82
+ }
83
+ query += ' GROUP BY ' + entityTable.tab_column;
84
+ return await this.entityManager.query(query, whereClause.argumentList);
85
+ }
86
+
87
+ private getQuery(source: string, groupByColumn: string | null) {
88
+ if (groupByColumn) {
89
+ return `SELECT ${groupByColumn} as tab_value, COUNT(1) AS tab_value_count
90
+ FROM ${source}`;
91
+ } else {
92
+ return `SELECT *
93
+ FROM ${source}`;
94
+ }
95
+ }
96
+
97
+ private async getWhereClause(
98
+ entityTable: EntityTable,
99
+ filterCriteria?: Record<string, any>,
100
+ ) {
101
+ let query = ' WHERE 1=1 ';
102
+ const argsObjectList: any[] = [];
103
+
104
+ const attributeMap = await this.entityTableColumnService.getAttributeJson(
105
+ entityTable.id,
106
+ entityTable.entity_type,
107
+ );
108
+
109
+ if (filterCriteria && Object.keys(filterCriteria).length > 0) {
110
+ for (const [columnName, value] of Object.entries(filterCriteria)) {
111
+ let column = columnName.endsWith('__from')
112
+ ? columnName.replace('__from', '')
113
+ : columnName;
114
+
115
+ if (attributeMap[column]) {
116
+ if (attributeMap[column].toLowerCase() === 'label') {
117
+ query += ` AND ${column} LIKE ?`;
118
+ argsObjectList.push(`%${value}%`);
119
+ } else if (attributeMap[column].toLowerCase() === 'date') {
120
+ query += ` AND DATE(${column}) BETWEEN DATE(?) AND DATE(?)`;
121
+ argsObjectList.push(
122
+ filterCriteria[column + '__from'],
123
+ filterCriteria[column + '__to'],
124
+ );
125
+ } else {
126
+ query += ` AND ${column} = ?`;
127
+ argsObjectList.push(value);
128
+ }
129
+ } else if (column.toLowerCase() === 'searchtext') {
130
+ query += ` AND code LIKE ?`;
131
+ argsObjectList.push(`%${value}%`);
132
+ }
133
+ }
134
+ }
135
+
136
+ return { query, argumentList: argsObjectList };
137
+ }
138
+ }
@@ -4,13 +4,16 @@ 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';
6
6
  import { BaseEntity } from '../entity/base-entity.entity';
7
- import {LoggingService} from "../../../utils/service/loggingUtil.service";
7
+ import { LoggingService } from '../../../utils/service/loggingUtil.service';
8
+ import { EntityListData } from '../dto/entity-list-data.dto';
9
+ import { EntityListService } from './entity-list.service';
8
10
 
9
11
  @Injectable()
10
12
  export class EntityServiceImpl implements EntityService<BaseEntity> {
11
13
  constructor(
12
14
  private entityMasterService: EntityMasterService,
13
15
  private reflectionHelper: ReflectionHelper,
16
+ private entityListService: EntityListService,
14
17
  loggingService: LoggingService,
15
18
  ) {}
16
19
 
@@ -126,6 +129,26 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
126
129
  entityData.modified_by = loggedInUserData.id;
127
130
  }
128
131
  await repoService.update(entityData.id, entityData);
129
- return await repoService.findOne({where : {id : entityData.id}})
132
+ return await repoService.findOne({ where: { id: entityData.id } });
133
+ }
134
+
135
+ async getFilterDataWithTabs(
136
+ entityType: string,
137
+ listType: string,
138
+ filters: Record<string, any>,
139
+ sortColumn: string | undefined,
140
+ sortOrder: string | undefined,
141
+ pageNumber: number,
142
+ pageSize: number,
143
+ ): Promise<EntityListData> {
144
+ return await this.entityListService.getFilterDataWithTabs(
145
+ entityType,
146
+ listType,
147
+ filters,
148
+ sortColumn,
149
+ sortOrder,
150
+ pageNumber,
151
+ pageSize,
152
+ );
130
153
  }
131
154
  }
@@ -0,0 +1,18 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityTableColumnRepository } from '../repository/entity-table-column.repository';
3
+
4
+ @Injectable()
5
+ export class EntityTableColumnService {
6
+ constructor(
7
+ private entityTableColumnRepository: EntityTableColumnRepository,
8
+ ) {}
9
+
10
+ async getAttributeJson(parentId: number, parentType: string) {
11
+ let entityTableColumns = await this.entityTableColumnRepository.findByParentIdAndParentType(parentId, parentType);
12
+ let attributeJson = {};
13
+ entityTableColumns.forEach((value) => {
14
+ attributeJson[value.attribute_key] = value.data_type;
15
+ });
16
+ return attributeJson;
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { EntityTableRepository } from '../repository/entity-table.repository';
3
+
4
+ @Injectable()
5
+ export class EntityTableService {
6
+ constructor(private entityTableRepository: EntityTableRepository) {}
7
+
8
+ async findByEntityTypeAndListType(entityType: string, listType: string) {
9
+ return await this.entityTableRepository.findByEntityTypeAndListType(entityType, listType);
10
+ }
11
+ }
@@ -1,5 +1,6 @@
1
1
  import { UserData } from '../../user/entity/user.entity';
2
2
  import { BaseEntity } from '../entity/base-entity.entity';
3
+ import { EntityListData } from '../dto/entity-list-data.dto';
3
4
 
4
5
  export interface EntityService<T extends BaseEntity> {
5
6
  createEntity(entityData: T, loggedInUser: UserData): Promise<BaseEntity>;
@@ -20,4 +21,14 @@ export interface EntityService<T extends BaseEntity> {
20
21
  ): void;
21
22
 
22
23
  findByCode(entityType: string, code: string): Promise<BaseEntity>;
24
+
25
+ getFilterDataWithTabs(
26
+ entityType: string,
27
+ listType: string,
28
+ filters: Record<string, any>,
29
+ sortColumn: string | undefined,
30
+ sortOrder: string | undefined,
31
+ pageNumber: number,
32
+ pageSize: number,
33
+ ): Promise<EntityListData>;
23
34
  }