rez_core 1.0.9 → 1.0.11

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 (152) hide show
  1. package/data/master.xlsx +0 -0
  2. package/dist/config/config.module.js +1 -1
  3. package/dist/config/config.module.js.map +1 -1
  4. package/dist/decorators/roles.decorator.js.map +1 -1
  5. package/dist/module/enterprise/enterprise.module.js +1 -1
  6. package/dist/module/enterprise/enterprise.module.js.map +1 -1
  7. package/dist/module/enterprise/service/organization.service.d.ts +9 -7
  8. package/dist/module/enterprise/service/organization.service.js +35 -14
  9. package/dist/module/enterprise/service/organization.service.js.map +1 -1
  10. package/dist/module/master/controller/master.controller.js +1 -1
  11. package/dist/module/master/controller/master.controller.js.map +1 -1
  12. package/dist/module/meta/controller/entity.controller.d.ts +1 -0
  13. package/dist/module/meta/controller/entity.controller.js +37 -2
  14. package/dist/module/meta/controller/entity.controller.js.map +1 -1
  15. package/dist/module/meta/entity/base-entity.entity.js.map +1 -1
  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 +1 -0
  18. package/dist/module/meta/entity/entity-table.entity.js +4 -0
  19. package/dist/module/meta/entity/entity-table.entity.js.map +1 -1
  20. package/dist/module/meta/entity.module.js +8 -1
  21. package/dist/module/meta/entity.module.js.map +1 -1
  22. package/dist/module/meta/repository/entity-table-column.repository.js +2 -2
  23. package/dist/module/meta/repository/entity-table.repository.d.ts +1 -0
  24. package/dist/module/meta/repository/entity-table.repository.js +9 -0
  25. package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
  26. package/dist/module/meta/service/entity-list.service.d.ts +2 -1
  27. package/dist/module/meta/service/entity-list.service.js +12 -1
  28. package/dist/module/meta/service/entity-list.service.js.map +1 -1
  29. package/dist/module/meta/service/entity-service-impl.service.d.ts +11 -4
  30. package/dist/module/meta/service/entity-service-impl.service.js +67 -9
  31. package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
  32. package/dist/module/meta/service/entity-table-column.service.d.ts +1 -0
  33. package/dist/module/meta/service/entity-table-column.service.js +4 -0
  34. package/dist/module/meta/service/entity-table-column.service.js.map +1 -1
  35. package/dist/module/meta/service/entity-table.service.d.ts +1 -0
  36. package/dist/module/meta/service/entity-table.service.js +3 -0
  37. package/dist/module/meta/service/entity-table.service.js.map +1 -1
  38. package/dist/module/meta/service/entity.service.d.ts +1 -0
  39. package/dist/module/meta/service/preference.service.d.ts +1 -5
  40. package/dist/module/meta/service/preference.service.js +3 -11
  41. package/dist/module/meta/service/preference.service.js.map +1 -1
  42. package/dist/module/module/controller/menu.controller.js +1 -1
  43. package/dist/module/module/controller/menu.controller.js.map +1 -1
  44. package/dist/module/module/controller/module-access.controller.js +1 -1
  45. package/dist/module/module/controller/module-access.controller.js.map +1 -1
  46. package/dist/module/module/entity/menu.entity.js.map +1 -1
  47. package/dist/module/module/entity/module.entity.js.map +1 -1
  48. package/dist/module/module/module.module.js +2 -2
  49. package/dist/module/module/module.module.js.map +1 -1
  50. package/dist/module/module/repository/menu.repository.js +3 -3
  51. package/dist/module/module/repository/menu.repository.js.map +1 -1
  52. package/dist/module/module/repository/module-access.repository.js +31 -20
  53. package/dist/module/module/repository/module-access.repository.js.map +1 -1
  54. package/dist/module/module/service/menu.service.js +2 -2
  55. package/dist/module/module/service/menu.service.js.map +1 -1
  56. package/dist/module/module/service/module-access.service.js.map +1 -1
  57. package/dist/module/notification/controller/otp.controller.d.ts +11 -0
  58. package/dist/module/notification/controller/otp.controller.js +56 -0
  59. package/dist/module/notification/controller/otp.controller.js.map +1 -0
  60. package/dist/module/notification/entity/otp.entity.d.ts +10 -0
  61. package/dist/module/notification/entity/otp.entity.js +52 -0
  62. package/dist/module/notification/entity/otp.entity.js.map +1 -0
  63. package/dist/module/notification/notification.module.d.ts +2 -0
  64. package/dist/module/notification/notification.module.js +27 -0
  65. package/dist/module/notification/notification.module.js.map +1 -0
  66. package/dist/module/notification/repository/otp.repository.d.ts +9 -0
  67. package/dist/module/notification/repository/otp.repository.js +44 -0
  68. package/dist/module/notification/repository/otp.repository.js.map +1 -0
  69. package/dist/module/notification/service/otp.service.d.ts +12 -0
  70. package/dist/module/notification/service/otp.service.js +61 -0
  71. package/dist/module/notification/service/otp.service.js.map +1 -0
  72. package/dist/module/user/controller/login.controller.js +1 -1
  73. package/dist/module/user/controller/login.controller.js.map +1 -1
  74. package/dist/module/user/controller/user.controller.js +1 -1
  75. package/dist/module/user/controller/user.controller.js.map +1 -1
  76. package/dist/module/user/dto/create-user.dto.js.map +1 -1
  77. package/dist/module/user/entity/role.entity.js.map +1 -1
  78. package/dist/module/user/repository/user-role-mapping.repository.js +4 -1
  79. package/dist/module/user/repository/user-role-mapping.repository.js.map +1 -1
  80. package/dist/module/user/repository/user.repository.js.map +1 -1
  81. package/dist/module/user/service/role.service.d.ts +1 -5
  82. package/dist/module/user/service/role.service.js +3 -10
  83. package/dist/module/user/service/role.service.js.map +1 -1
  84. package/dist/module/user/service/user.service.d.ts +1 -5
  85. package/dist/module/user/service/user.service.js +3 -11
  86. package/dist/module/user/service/user.service.js.map +1 -1
  87. package/dist/module/user/user.module.js.map +1 -1
  88. package/dist/tsconfig.build.tsbuildinfo +1 -1
  89. package/dist/utils/dto/excel-data.dto.d.ts +7 -0
  90. package/dist/utils/dto/excel-data.dto.js +16 -0
  91. package/dist/utils/dto/excel-data.dto.js.map +1 -0
  92. package/dist/utils/dto/excelsheet-data.dto.d.ts +5 -0
  93. package/dist/utils/dto/excelsheet-data.dto.js +3 -0
  94. package/dist/utils/dto/excelsheet-data.dto.js.map +1 -0
  95. package/dist/utils/service/excel-helper.service.d.ts +3 -1
  96. package/dist/utils/service/excel-helper.service.js +12 -3
  97. package/dist/utils/service/excel-helper.service.js.map +1 -1
  98. package/dist/utils/service/loggingUtil.service.js +6 -6
  99. package/dist/utils/service/loggingUtil.service.js.map +1 -1
  100. package/dist/utils/utils.module.js.map +1 -1
  101. package/package.json +1 -1
  102. package/src/config/config.module.ts +1 -1
  103. package/src/decorators/roles.decorator.ts +5 -2
  104. package/src/module/auth/guards/google-auth.guard.ts +1 -1
  105. package/src/module/enterprise/enterprise.module.ts +2 -3
  106. package/src/module/enterprise/service/organization.service.ts +48 -13
  107. package/src/module/master/controller/master.controller.ts +1 -1
  108. package/src/module/meta/controller/entity.controller.ts +56 -4
  109. package/src/module/meta/entity/base-entity.entity.ts +1 -1
  110. package/src/module/meta/entity/entity-table-column.entity.ts +1 -1
  111. package/src/module/meta/entity/entity-table.entity.ts +4 -2
  112. package/src/module/meta/entity.module.ts +8 -1
  113. package/src/module/meta/repository/entity-table-column.repository.ts +3 -3
  114. package/src/module/meta/repository/entity-table.repository.ts +14 -0
  115. package/src/module/meta/service/entity-list.service.ts +15 -5
  116. package/src/module/meta/service/entity-service-impl.service.ts +98 -8
  117. package/src/module/meta/service/entity-table-column.service.ts +14 -1
  118. package/src/module/meta/service/entity-table.service.ts +8 -1
  119. package/src/module/meta/service/entity.service.ts +12 -1
  120. package/src/module/meta/service/preference.service.ts +2 -17
  121. package/src/module/module/controller/menu.controller.ts +1 -1
  122. package/src/module/module/controller/module-access.controller.ts +2 -2
  123. package/src/module/module/entity/menu.entity.ts +9 -9
  124. package/src/module/module/entity/module.entity.ts +8 -8
  125. package/src/module/module/module.module.ts +2 -4
  126. package/src/module/module/repository/menu.repository.ts +7 -10
  127. package/src/module/module/repository/module-access.repository.ts +57 -42
  128. package/src/module/module/service/menu.service.ts +9 -10
  129. package/src/module/module/service/module-access.service.ts +8 -3
  130. package/src/module/notification/controller/otp.controller.ts +25 -0
  131. package/src/module/notification/entity/otp.entity.ts +28 -0
  132. package/src/module/notification/notification.module.ts +14 -0
  133. package/src/module/notification/repository/otp.repository.ts +27 -0
  134. package/src/module/notification/service/otp.service.ts +50 -0
  135. package/src/module/user/controller/login.controller.ts +1 -1
  136. package/src/module/user/controller/user.controller.ts +1 -1
  137. package/src/module/user/dto/create-user.dto.ts +43 -43
  138. package/src/module/user/entity/role.entity.ts +1 -1
  139. package/src/module/user/repository/user-role-mapping.repository.ts +9 -3
  140. package/src/module/user/repository/user.repository.ts +2 -2
  141. package/src/module/user/service/role.service.ts +2 -13
  142. package/src/module/user/service/user-role-mapping.service.ts +1 -1
  143. package/src/module/user/service/user-session.service.ts +1 -1
  144. package/src/module/user/service/user.service.ts +5 -18
  145. package/src/module/user/user.module.ts +0 -1
  146. package/src/utils/dto/excel-data.dto.ts +14 -0
  147. package/src/utils/dto/excelsheet-data.dto.ts +5 -0
  148. package/src/utils/service/clockIDGenUtil.service.ts +1 -1
  149. package/src/utils/service/dateUtil.service.ts +1 -1
  150. package/src/utils/service/excel-helper.service.ts +14 -1
  151. package/src/utils/service/loggingUtil.service.ts +48 -48
  152. package/src/utils/utils.module.ts +7 -7
@@ -0,0 +1,7 @@
1
+ import { ExcelsheetData } from './excelsheet-data.dto';
2
+ export declare class ExcelData {
3
+ filePath: string;
4
+ sheetList: ExcelsheetData[];
5
+ addSheet(sheetData: ExcelsheetData): void;
6
+ addSheetAt(sheetData: ExcelsheetData, position: number): void;
7
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExcelData = void 0;
4
+ class ExcelData {
5
+ constructor() {
6
+ this.sheetList = [];
7
+ }
8
+ addSheet(sheetData) {
9
+ this.sheetList.push(sheetData);
10
+ }
11
+ addSheetAt(sheetData, position) {
12
+ this.sheetList.splice(position, 0, sheetData);
13
+ }
14
+ }
15
+ exports.ExcelData = ExcelData;
16
+ //# sourceMappingURL=excel-data.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excel-data.dto.js","sourceRoot":"","sources":["../../../src/utils/dto/excel-data.dto.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAS;IAAtB;QAEE,cAAS,GAAqB,EAAE,CAAC;IASnC,CAAC;IAPC,QAAQ,CAAC,SAAyB;QAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,SAAyB,EAAE,QAAgB;QACpD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;CACF;AAXD,8BAWC"}
@@ -0,0 +1,5 @@
1
+ export interface ExcelsheetData {
2
+ sheetName: string;
3
+ headers: string[];
4
+ rowList: any[][];
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=excelsheet-data.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"excelsheet-data.dto.js","sourceRoot":"","sources":["../../../src/utils/dto/excelsheet-data.dto.ts"],"names":[],"mappings":""}
@@ -1,7 +1,9 @@
1
- export declare class ExcelHelperService {
1
+ import { ExcelData } from '../dto/excel-data.dto';
2
+ export declare class ExcelHelper {
2
3
  static getHeader(filePath: string, sheetName: string): string[];
3
4
  static readExcel(filePath: string, rowLevel: string, sheetName: string): string[][];
4
5
  static getRowData(filePath: string, sheetName: string): string[][];
5
6
  static getJSONStringFromList(header: string[], rowData: string[][]): string;
6
7
  static getDataObjectListFromXLS<T>(filePath: string, sheetName: string, classType: new () => T): T[];
8
+ static writeExcel(excelData: ExcelData): void;
7
9
  }
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExcelHelperService = void 0;
3
+ exports.ExcelHelper = void 0;
4
4
  const ExcelJS = require("exceljs");
5
- class ExcelHelperService {
5
+ const XLSX = require("xlsx");
6
+ class ExcelHelper {
6
7
  static getHeader(filePath, sheetName) {
7
8
  const rows = this.readExcel(filePath, 'HEADER', sheetName);
8
9
  return rows.length > 0 ? rows[0] : [];
@@ -39,6 +40,14 @@ class ExcelHelperService {
39
40
  const jsonString = this.getJSONStringFromList(header, rowData);
40
41
  return JSON.parse(jsonString);
41
42
  }
43
+ static writeExcel(excelData) {
44
+ const wb = XLSX.utils.book_new();
45
+ for (const sheetData of excelData.sheetList) {
46
+ const ws = XLSX.utils.aoa_to_sheet([sheetData.headers, ...sheetData.rowList]);
47
+ XLSX.utils.book_append_sheet(wb, ws, sheetData.sheetName || 'Sheet1');
48
+ }
49
+ XLSX.writeFile(wb, excelData.filePath);
50
+ }
42
51
  }
43
- exports.ExcelHelperService = ExcelHelperService;
52
+ exports.ExcelHelper = ExcelHelper;
44
53
  //# sourceMappingURL=excel-helper.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"excel-helper.service.js","sourceRoot":"","sources":["../../../src/utils/service/excel-helper.service.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEnC,MAAa,kBAAkB;IAC7B,MAAM,CAAC,SAAS,CAAC,QAAgB,EAAE,SAAiB;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,SAAS,CACd,QAAgB,EAChB,QAAgB,EAChB,SAAiB;QAEjB,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,SAAS,SAAS,YAAY,CAAC,CAAC;QAE5D,MAAM,MAAM,GAAe,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;YAC/B,IAAI,QAAQ,KAAK,QAAQ,IAAI,SAAS,GAAG,CAA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I,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEjC,KAAK,MAAM,SAAS,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAC9E,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,SAAS,IAAI,QAAQ,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACF;AAhED,kCAgEC"}
@@ -20,21 +20,21 @@ let LoggingService = class LoggingService {
20
20
  let levelInfo = level.toLowerCase().trim();
21
21
  let logger = new common_1.Logger(serviceName);
22
22
  const fileConfiguration = {
23
- format: winston.format.combine(winston.format.errors({ stzack: true }), winston.format.timestamp({ format: 'DD/MM/YYYY HH:mm:ss' }), winston.format.printf(info => `${info.timestamp} : ${info.level}: ${serviceName}: ${methodName} : ${message} : ${JSON.stringify(parameters) || ""} : ${JSON.stringify(debuginfo) || ""}`)),
23
+ format: winston.format.combine(winston.format.errors({ stzack: true }), winston.format.timestamp({ format: 'DD/MM/YYYY HH:mm:ss' }), winston.format.printf((info) => `${info.timestamp} : ${info.level}: ${serviceName}: ${methodName} : ${message} : ${JSON.stringify(parameters) || ''} : ${JSON.stringify(debuginfo) || ''}`)),
24
24
  transports: [
25
25
  new winston_1.transports.File({
26
- dirname: `/data01/logs/${moment().format("DD-MM-YYYY")}/activity/${moment().format("HH dddd")}`,
26
+ dirname: `/data01/logs/${moment().format('DD-MM-YYYY')}/activity/${moment().format('HH dddd')}`,
27
27
  filename: 'activity.log',
28
- level: `${level}`
29
- })
28
+ level: `${level}`,
29
+ }),
30
30
  ],
31
31
  };
32
32
  const filelogger = winston.createLogger(fileConfiguration);
33
33
  let data = `${message} -- Parameters: ${JSON.stringify(parameters)}`;
34
- if (levelInfo == "debug" || levelInfo == "info") {
34
+ if (levelInfo == 'debug' || levelInfo == 'info') {
35
35
  logger.debug(`${methodName} : ${message} : Parameters :${JSON.stringify(parameters)}: Debug Info: ${JSON.stringify(debuginfo)}`);
36
36
  }
37
- else if (levelInfo == "error") {
37
+ else if (levelInfo == 'error') {
38
38
  logger.error(`${methodName} : ${message} : Parameters :${JSON.stringify(parameters)}: Debug Info: ${JSON.stringify(debuginfo)}`);
39
39
  }
40
40
  filelogger.on('finish', () => { });
@@ -1 +1 @@
1
- {"version":3,"file":"loggingUtil.service.js","sourceRoot":"","sources":["../../../src/utils/service/loggingUtil.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,qCAAqC;AACrC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAG1B,IAAM,cAAc,GAApB,MAAM,cAAc;IAEvB,gBACI,CAAC;IAIL,KAAK,CAAC,GAAG,CACL,KAAa,EACb,WAAmB,EACnB,UAAkB,EAClB,OAAe,EACf,UAAsB,EACtB,SAAqB;QAGrB,IAAI,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;QAC3C,IAAI,MAAM,GAAG,IAAI,eAAM,CAAC,WAAW,CAAC,CAAC;QAErC,MAAM,iBAAiB,GAAG;YACtB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACvC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,EAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,MAA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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"}
1
+ {"version":3,"file":"utils.module.js","sourceRoot":"","sources":["../../src/utils/utils.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,uEAA+D;AAC/D,mFAAuE;AACvE,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,EAAE,6BAAS,EAAE,0CAAiB,CAAC;QAC3E,OAAO,EAAE,CAAC,oCAAc,EAAE,4CAAgB,EAAE,6BAAS,EAAE,0CAAiB,CAAC;KAC1E,CAAC;GACW,WAAW,CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -10,7 +10,7 @@ import { MySqlConfiguration } from './database.config';
10
10
  TypeOrmModule.forRootAsync({
11
11
  useClass: MySqlConfiguration,
12
12
  }),
13
- ConfigModule.forRoot({isGlobal: true})
13
+ ConfigModule.forRoot({ isGlobal: true }),
14
14
  ],
15
15
  // providers: [MySqlConfiguration],
16
16
  exports: [TypeOrmModule],
@@ -1,4 +1,7 @@
1
- import {applyDecorators, SetMetadata} from "@nestjs/common";
1
+ import { applyDecorators, SetMetadata } from '@nestjs/common';
2
2
 
3
3
  export const Roles = (moduleCode: string, actions: string) =>
4
- applyDecorators(SetMetadata('moduleCode', moduleCode), SetMetadata('actions', actions));
4
+ applyDecorators(
5
+ SetMetadata('moduleCode', moduleCode),
6
+ SetMetadata('actions', actions),
7
+ );
@@ -1,4 +1,4 @@
1
- import { Injectable, ExecutionContext } from '@nestjs/common';
1
+ import { ExecutionContext, Injectable } from '@nestjs/common';
2
2
  import { AuthGuard } from '@nestjs/passport';
3
3
 
4
4
  @Injectable()
@@ -1,12 +1,11 @@
1
1
  import { Module } from '@nestjs/common';
2
2
  import { TypeOrmModule } from '@nestjs/typeorm';
3
- import { UserData } from '../user/entity/user.entity';
4
3
  import { OrganizationService } from './service/organization.service';
5
4
  import { OrganizationData } from './entity/organization.entity';
6
5
 
7
6
  @Module({
8
7
  imports: [TypeOrmModule.forFeature([OrganizationData])],
9
- providers:[OrganizationService],
10
- exports:[OrganizationService]
8
+ providers: [OrganizationService],
9
+ exports: [OrganizationService],
11
10
  })
12
11
  export class EnterpriseModule {}
@@ -1,34 +1,69 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { Repository } from 'typeorm';
3
+ import { EntityManager, Repository } from 'typeorm';
4
4
  import { OrganizationData } from '../entity/organization.entity';
5
+ import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
5
6
 
6
7
  @Injectable()
7
8
  export class OrganizationService {
8
9
  constructor(
9
10
  @InjectRepository(OrganizationData)
10
11
  private readonly organizationRepository: Repository<OrganizationData>,
12
+ private readonly idGen: ClockIDGenService,
11
13
  ) {}
12
14
 
13
- async create(organizationDto: Partial<OrganizationData>): Promise<OrganizationData> {
14
- const organization = this.organizationRepository.create(organizationDto);
15
- return await this.organizationRepository.save(organization);
15
+ async create(
16
+ organizationDto: Partial<OrganizationData>,
17
+ manager?: EntityManager,
18
+ ): Promise<OrganizationData> {
19
+ const repo = manager
20
+ ? manager.getRepository(OrganizationData)
21
+ : this.organizationRepository;
22
+
23
+ organizationDto.code = this.idGen.idGenerator('ORG');
24
+ organizationDto.status = 'ACTIVE';
25
+ organizationDto.created_date = new Date();
26
+ const organization = repo.create(organizationDto);
27
+ return await repo.save(organization);
16
28
  }
17
29
 
18
- async findAll(): Promise<OrganizationData[]> {
19
- return await this.organizationRepository.find();
30
+ async findAll(manager?: EntityManager): Promise<OrganizationData[]> {
31
+ const repo = manager
32
+ ? manager.getRepository(OrganizationData)
33
+ : this.organizationRepository;
34
+
35
+ return await repo.find();
20
36
  }
21
37
 
22
- async findOne(id: number): Promise<OrganizationData | null> {
23
- return await this.organizationRepository.findOne({ where: { id } });
38
+ async findOne(
39
+ id: number,
40
+ manager?: EntityManager,
41
+ ): Promise<OrganizationData | null> {
42
+ const repo = manager
43
+ ? manager.getRepository(OrganizationData)
44
+ : this.organizationRepository;
45
+
46
+ return await repo.findOne({ where: { id } });
24
47
  }
25
48
 
26
- async update(id: number, organizationDto: Partial<OrganizationData>): Promise<OrganizationData | null> {
27
- await this.organizationRepository.update(id, organizationDto);
28
- return this.findOne(id);
49
+ async update(
50
+ id: number,
51
+ organizationDto: Partial<OrganizationData>,
52
+ manager?: EntityManager,
53
+ ): Promise<OrganizationData | null> {
54
+ const repo = manager
55
+ ? manager.getRepository(OrganizationData)
56
+ : this.organizationRepository;
57
+
58
+ await repo.update(id, organizationDto);
59
+ return await repo.findOne({ where: { id } });
29
60
  }
30
61
 
31
- async remove(id: number): Promise<void> {
32
- await this.organizationRepository.delete(id);
62
+ async remove(id: number, manager?: EntityManager): Promise<void> {
63
+ const repo = manager
64
+ ? manager.getRepository(OrganizationData)
65
+ : this.organizationRepository;
66
+
67
+ await repo.delete(id);
33
68
  }
34
69
  }
@@ -7,7 +7,7 @@ import {
7
7
  import { FileInterceptor } from '@nestjs/platform-express';
8
8
  import { MasterService } from '../service/master.service';
9
9
 
10
- @Controller('master')
10
+ @Controller('api/master')
11
11
  export class MasterController {
12
12
  constructor(private readonly masterService: MasterService) {}
13
13
 
@@ -2,7 +2,7 @@ import {
2
2
  BadRequestException,
3
3
  Body,
4
4
  Controller,
5
- Get,
5
+ Get, HttpCode,
6
6
  HttpStatus,
7
7
  Param,
8
8
  Post,
@@ -16,9 +16,11 @@ import { Response } from 'express';
16
16
  import { EntityMasterService } from '../service/entity-master.service';
17
17
  import { BaseEntity } from '../entity/base-entity.entity';
18
18
  import { JwtAuthGuard } from '../../auth/guards/jwt.guard';
19
+ import * as fs from 'fs';
20
+ import * as path from 'path';
19
21
 
20
22
  @UseGuards(JwtAuthGuard)
21
- @Controller('entity')
23
+ @Controller('api/entity')
22
24
  export class EntityController {
23
25
  constructor(
24
26
  private entityService: EntityServiceImpl,
@@ -120,8 +122,58 @@ export class EntityController {
120
122
  @Query('page') page: number = 0,
121
123
  @Query('size') size: number = 1,
122
124
  ) {
125
+ return res
126
+ .status(HttpStatus.OK)
127
+ .json(
128
+ await this.entityService.getFilterDataWithTabs(
129
+ entityType,
130
+ listType,
131
+ filters,
132
+ sortColumn,
133
+ sortOrder,
134
+ page,
135
+ size,
136
+ ),
137
+ );
138
+ }
139
+
140
+ @HttpCode(HttpStatus.OK)
141
+ @Post('download-excel/:entity_type')
142
+ async downloadExcel(
143
+ @Param('entity_type') entityType: string,
144
+ @Query('list_entity_type') listEntityType: string,
145
+ @Query('display_type') displayType: string,
146
+ @Query() filterCriteria: Record<string, any>,
147
+ @Res() res: Response, // Express Response for file handling
148
+ ) {
149
+ try {
150
+ const filePath = await this.entityService.generateExcelReport(
151
+ entityType,
152
+ filterCriteria,
153
+ listEntityType,
154
+ displayType,
155
+ );
123
156
 
124
- return res.status(HttpStatus.OK).json(await this.entityService.getFilterDataWithTabs(entityType, listType,
125
- filters, sortColumn, sortOrder, page, size));
157
+ if (!filePath || !fs.existsSync(filePath)) {
158
+ return res.status(404).json({ message: 'File not found' });
159
+ }
160
+
161
+ res.setHeader(
162
+ 'Content-Disposition',
163
+ `attachment; filename=${path.basename(filePath)}`,
164
+ );
165
+ res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
166
+
167
+ const fileStream = fs.createReadStream(filePath);
168
+ fileStream.pipe(res);
169
+
170
+ // Optional: Delete file after sending response
171
+ fileStream.on('end', () => {
172
+ fs.unlinkSync(filePath);
173
+ });
174
+ } catch (error) {
175
+ console.error('Error downloading Excel file:', error);
176
+ res.status(500).json({ message: 'Internal server error' });
177
+ }
126
178
  }
127
179
  }
@@ -1,6 +1,6 @@
1
1
  import { Column, PrimaryGeneratedColumn } from 'typeorm';
2
2
  import { StatusType } from '../../../constant/status.constant';
3
- import {Expose} from "class-transformer";
3
+ import { Expose } from 'class-transformer';
4
4
 
5
5
  export class BaseEntity {
6
6
  constructor() {
@@ -1,5 +1,5 @@
1
1
  import { ENTITYTYPE_ENTITYTABLECOLUMN } from '../../../constant/global.constant';
2
- import {Column, Entity} from 'typeorm';
2
+ import { Column, Entity } from 'typeorm';
3
3
  import { BaseEntity } from './base-entity.entity';
4
4
 
5
5
  @Entity({ name: 'cr_entity_table_column' })
@@ -1,10 +1,9 @@
1
1
  import { Column, Entity } from 'typeorm';
2
2
  import { BaseEntity } from './base-entity.entity';
3
- import {ENTITYTYPE_ENTITYTABLE} from "../../../constant/global.constant";
3
+ import { ENTITYTYPE_ENTITYTABLE } from '../../../constant/global.constant';
4
4
 
5
5
  @Entity({ name: 'cr_entity_table' })
6
6
  export class EntityTable extends BaseEntity {
7
-
8
7
  constructor() {
9
8
  super();
10
9
  this.entity_type = ENTITYTYPE_ENTITYTABLE;
@@ -48,4 +47,7 @@ export class EntityTable extends BaseEntity {
48
47
 
49
48
  @Column({ name: 'is_proc', nullable: true })
50
49
  is_proc: number;
50
+
51
+ @Column({ name: 'display_type', nullable: true})
52
+ display_type: string;
51
53
  }
@@ -44,7 +44,14 @@ import { EntityListService } from './service/entity-list.service';
44
44
  EntityTableColumnService,
45
45
  EntityListService,
46
46
  ],
47
- exports: [EntityMasterService, EntityServiceImpl, PreferenceService, EntityListService],
47
+ exports: [
48
+ EntityMasterService,
49
+ EntityServiceImpl,
50
+ PreferenceService,
51
+ EntityListService,
52
+ EntityTableService,
53
+ EntityTableColumnService
54
+ ],
48
55
  controllers: [EntityController, MasterController],
49
56
  })
50
57
  export class EntityModule {}
@@ -10,12 +10,12 @@ export class EntityTableColumnRepository {
10
10
  private entityTableColumnRepository: Repository<EntityTableColumn>,
11
11
  ) {}
12
12
 
13
- async findByParentIdAndParentType(parentId: number, parentType: string){
13
+ async findByParentIdAndParentType(parentId: number, parentType: string) {
14
14
  return await this.entityTableColumnRepository.find({
15
15
  where: {
16
16
  parent_id: parentId,
17
- parent_type: parentType
18
- }
17
+ parent_type: parentType,
18
+ },
19
19
  });
20
20
  }
21
21
  }
@@ -15,4 +15,18 @@ export class EntityTableRepository {
15
15
  where: { mapped_entity_type: entityType, list_type: listType },
16
16
  });
17
17
  }
18
+
19
+ async findByEntityTypeAndListTypeAndDisplayType(
20
+ entityType: string,
21
+ listType: string,
22
+ displayType: string,
23
+ ) {
24
+ return await this.entityTableRepository.findOne({
25
+ where: {
26
+ mapped_entity_type: entityType,
27
+ list_type: listType,
28
+ display_type: displayType,
29
+ },
30
+ });
31
+ }
18
32
  }
@@ -49,13 +49,13 @@ export class EntityListService {
49
49
  return entityListData;
50
50
  }
51
51
 
52
- private async getFilteredList(
52
+ public async getFilteredList(
53
53
  entityTable: EntityTable,
54
54
  filters: Record<string, any>,
55
55
  sortColumn: string | undefined,
56
56
  sortOrder: string | undefined,
57
- pageNumber: number,
58
- pageSize: number,
57
+ pageNumber: number | undefined,
58
+ pageSize: number | undefined,
59
59
  ) {
60
60
  let query = this.getQuery(entityTable.data_source, null);
61
61
  let whereClause = await this.getWhereClause(entityTable, filters);
@@ -75,13 +75,23 @@ export class EntityListService {
75
75
  entityTable: EntityTable,
76
76
  filters: Record<string, any>,
77
77
  ) {
78
- let query = this.getQuery(entityTable.data_source, entityTable.tab_column);
78
+ let query = this.getQuery(entityTable.data_source, entityTable.tab_column);
79
79
  let whereClause = await this.getWhereClause(entityTable, filters);
80
80
  if (whereClause.query) {
81
81
  query += whereClause.query;
82
82
  }
83
83
  query += ' GROUP BY ' + entityTable.tab_column;
84
- return await this.entityManager.query(query, whereClause.argumentList);
84
+ let tabs = await this.entityManager.query(query, whereClause.argumentList);
85
+ let all = 0;
86
+ for (const i in tabs) {
87
+ let tab = tabs[i] as EntityTab;
88
+ all += parseInt(String(tab.tab_value_count));
89
+ }
90
+ let entityTab = new EntityTab();
91
+ entityTab.tab_value = 'ALL';
92
+ entityTab.tab_value_count = all;
93
+ tabs.push(entityTab);
94
+ return tabs;
85
95
  }
86
96
 
87
97
  private getQuery(source: string, groupByColumn: string | null) {
@@ -1,5 +1,5 @@
1
1
  import { EntityService } from './entity.service';
2
- import { Injectable } from '@nestjs/common';
2
+ import { 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';
@@ -8,20 +8,30 @@ import { LoggingService } from '../../../utils/service/loggingUtil.service';
8
8
  import { EntityListData } from '../dto/entity-list-data.dto';
9
9
  import { EntityListService } from './entity-list.service';
10
10
  import { EntityManager } from 'typeorm';
11
+ import { ExcelData } from '../../../utils/dto/excel-data.dto';
12
+ import * as fs from 'fs';
13
+ import * as path from 'path';
14
+ import { ExcelHelper } from '../../../utils/service/excel-helper.service';
15
+ import { ExcelsheetData } from '../../../utils/dto/excelsheet-data.dto';
16
+ import { EntityTableService } from './entity-table.service';
17
+ import { EntityTableColumnService } from './entity-table-column.service';
11
18
 
12
19
  @Injectable()
13
20
  export class EntityServiceImpl implements EntityService<BaseEntity> {
14
- constructor(
15
- private entityMasterService: EntityMasterService,
16
- private reflectionHelper: ReflectionHelper,
17
- private entityListService: EntityListService,
18
- loggingService: LoggingService,
19
- ) {}
21
+ @Inject() protected readonly entityMasterService: EntityMasterService;
22
+ @Inject()
23
+ protected readonly entityTableColumnService: EntityTableColumnService;
24
+ @Inject() protected readonly entityTableService: EntityTableService;
25
+ @Inject() protected readonly reflectionHelper: ReflectionHelper;
26
+ @Inject() protected readonly entityListService: EntityListService;
27
+ @Inject() protected readonly loggingService: LoggingService;
28
+
29
+ constructor() {}
20
30
 
21
31
  async createEntity(
22
32
  entityData: BaseEntity,
23
33
  loggedInUser: UserData | null,
24
- manager?: EntityManager
34
+ manager?: EntityManager,
25
35
  ): Promise<BaseEntity> {
26
36
  const entityMaster = await this.entityMasterService.getEntityData(
27
37
  entityData.entity_type,
@@ -154,4 +164,84 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
154
164
  pageSize,
155
165
  );
156
166
  }
167
+
168
+ async generateExcelReport(
169
+ entityType: string,
170
+ filterCriteria: Record<string, any>,
171
+ listEntityType: string,
172
+ displayType: string,
173
+ ): Promise<string | null> {
174
+ let fileName: string;
175
+ try {
176
+ const excelData = new ExcelData();
177
+ await this.populateExcelData(
178
+ excelData,
179
+ entityType,
180
+ filterCriteria,
181
+ listEntityType,
182
+ displayType,
183
+ );
184
+
185
+ const modifiedDate = new Date().toISOString().replace(/[-T:.Z]/g, '');
186
+ const tempDir = path.join(__dirname, '../../temp');
187
+ if (!fs.existsSync(tempDir)) {
188
+ fs.mkdirSync(tempDir, { recursive: true });
189
+ }
190
+ fileName = path.join(tempDir, `export_${modifiedDate}.xlsx`);
191
+ excelData.filePath = fileName;
192
+ ExcelHelper.writeExcel(excelData);
193
+ } catch (error) {
194
+ throw error;
195
+ }
196
+ return fileName;
197
+ }
198
+
199
+ private async populateExcelData(
200
+ excelData: ExcelData,
201
+ entityType: string,
202
+ filterCriteria: Record<string, any>,
203
+ listEntityType: string,
204
+ displayType: string,
205
+ ) {
206
+ const sheet: ExcelsheetData = {
207
+ sheetName: entityType,
208
+ headers: [],
209
+ rowList: [],
210
+ };
211
+
212
+ const entityTable =
213
+ await this.entityTableService.findByEntityTypeAndListTypeAndDisplayType(
214
+ entityType,
215
+ listEntityType,
216
+ displayType,
217
+ );
218
+ if (entityTable) {
219
+ const entityTableColumnList =
220
+ await this.entityTableColumnService.findByParentIdAndParentType(
221
+ entityTable.id,
222
+ entityTable.entity_type,
223
+ );
224
+
225
+ sheet.headers = entityTableColumnList.map((col) => col.name);
226
+ const attributeList = entityTableColumnList.map(
227
+ (col) => col.attribute_key,
228
+ );
229
+
230
+ const filteredList = await this.entityListService.getFilteredList(
231
+ entityTable,
232
+ filterCriteria,
233
+ undefined,
234
+ undefined,
235
+ undefined,
236
+ undefined,
237
+ );
238
+
239
+ sheet.rowList = filteredList.map((item) =>
240
+ attributeList.map((attr) =>
241
+ item[attr] !== undefined ? item[attr] : null,
242
+ ),
243
+ );
244
+ excelData.addSheet(sheet);
245
+ }
246
+ }
157
247
  }