rez_core 2.1.133 → 2.2.1

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 (122) hide show
  1. package/dist/module/enterprise/controller/organization.controller.d.ts +1 -1
  2. package/dist/module/enterprise/controller/organization.controller.js +1 -1
  3. package/dist/module/enterprise/controller/organization.controller.js.map +1 -1
  4. package/dist/module/enterprise/enterprise.module.js +7 -26
  5. package/dist/module/enterprise/enterprise.module.js.map +1 -1
  6. package/dist/module/enterprise/entity/organization.entity.d.ts +1 -0
  7. package/dist/module/enterprise/entity/organization.entity.js +4 -0
  8. package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
  9. package/dist/module/enterprise/repository/school.repository.d.ts +4 -6
  10. package/dist/module/enterprise/repository/school.repository.js +35 -33
  11. package/dist/module/enterprise/repository/school.repository.js.map +1 -1
  12. package/dist/module/enterprise/service/brand.service.d.ts +2 -1
  13. package/dist/module/enterprise/service/brand.service.js +2 -1
  14. package/dist/module/enterprise/service/brand.service.js.map +1 -1
  15. package/dist/module/enterprise/service/organization.service.d.ts +5 -7
  16. package/dist/module/enterprise/service/organization.service.js +48 -12
  17. package/dist/module/enterprise/service/organization.service.js.map +1 -1
  18. package/dist/module/filter/service/filter.service.js +1 -1
  19. package/dist/module/layout_preference/controller/layout_preference.controller.js +2 -2
  20. package/dist/module/layout_preference/controller/layout_preference.controller.js.map +1 -1
  21. package/dist/module/layout_preference/entity/layout_preference.entity.js +1 -1
  22. package/dist/module/layout_preference/entity/layout_preference.entity.js.map +1 -1
  23. package/dist/module/layout_preference/service/layout_preference.service.js +0 -7
  24. package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
  25. package/dist/module/lead/controller/lead.controller.d.ts +7 -7
  26. package/dist/module/lead/lead.module.js +1 -5
  27. package/dist/module/lead/lead.module.js.map +1 -1
  28. package/dist/module/lead/repository/lead.repository.d.ts +5 -8
  29. package/dist/module/lead/repository/lead.repository.js +16 -15
  30. package/dist/module/lead/repository/lead.repository.js.map +1 -1
  31. package/dist/module/lead/service/lead.service.d.ts +7 -7
  32. package/dist/module/meta/entity/brand-profile.entity.d.ts +3 -0
  33. package/dist/module/{enterprise/entity/brand.entity.js → meta/entity/brand-profile.entity.js} +8 -15
  34. package/dist/module/meta/entity/brand-profile.entity.js.map +1 -0
  35. package/dist/module/meta/entity/field-group.entity.d.ts +0 -9
  36. package/dist/module/meta/entity/field-group.entity.js +0 -46
  37. package/dist/module/meta/entity/field-group.entity.js.map +1 -1
  38. package/dist/module/meta/entity/section-master.entity.d.ts +0 -10
  39. package/dist/module/meta/entity/section-master.entity.js +0 -50
  40. package/dist/module/meta/entity/section-master.entity.js.map +1 -1
  41. package/dist/module/meta/entity/user-app-mapping.entity.d.ts +0 -7
  42. package/dist/module/meta/entity/user-app-mapping.entity.js +0 -40
  43. package/dist/module/meta/entity/user-app-mapping.entity.js.map +1 -1
  44. package/dist/module/meta/entity.module.js +2 -18
  45. package/dist/module/meta/entity.module.js.map +1 -1
  46. package/dist/module/meta/repository/user-app-mapping.repository.d.ts +0 -8
  47. package/dist/module/meta/repository/user-app-mapping.repository.js +0 -42
  48. package/dist/module/meta/repository/user-app-mapping.repository.js.map +1 -1
  49. package/dist/module/meta/service/user-app-mapping.service.d.ts +0 -7
  50. package/dist/module/meta/service/user-app-mapping.service.js +0 -30
  51. package/dist/module/meta/service/user-app-mapping.service.js.map +1 -1
  52. package/dist/module/meta/service/view-master.service.d.ts +1 -5
  53. package/dist/module/meta/service/view-master.service.js +2 -34
  54. package/dist/module/meta/service/view-master.service.js.map +1 -1
  55. package/dist/module/module/repository/menu.repository.js +1 -1
  56. package/dist/module/module/repository/module-access.repository.js +3 -1
  57. package/dist/module/module/repository/module-access.repository.js.map +1 -1
  58. package/dist/module/module/service/module-access.service.js +1 -1
  59. package/dist/module/module/service/module-access.service.js.map +1 -1
  60. package/dist/module/notification/entity/otp.entity.js +1 -1
  61. package/dist/module/notification/entity/otp.entity.js.map +1 -1
  62. package/dist/module/third-party-module/entity/third-party-api-registry.entity.js +1 -1
  63. package/dist/module/third-party-module/entity/third-party-api-registry.entity.js.map +1 -1
  64. package/dist/module/user/service/login.service.js +1 -1
  65. package/dist/module/user/service/login.service.js.map +1 -1
  66. package/dist/module/user/service/user-session.service.js +1 -1
  67. package/dist/module/user/service/user-session.service.js.map +1 -1
  68. package/dist/module/user/service/user.service.d.ts +1 -3
  69. package/dist/module/user/service/user.service.js +3 -6
  70. package/dist/module/user/service/user.service.js.map +1 -1
  71. package/dist/tsconfig.build.tsbuildinfo +1 -1
  72. package/dist/utils/service/wbsCodeGen.service.d.ts +3 -0
  73. package/dist/{module/enterprise/service/school.service.js → utils/service/wbsCodeGen.service.js} +9 -7
  74. package/dist/utils/service/wbsCodeGen.service.js.map +1 -0
  75. package/dist/utils/utils.module.js +15 -2
  76. package/dist/utils/utils.module.js.map +1 -1
  77. package/package.json +1 -1
  78. package/src/module/enterprise/controller/organization.controller.ts +1 -2
  79. package/src/module/enterprise/enterprise.module.ts +7 -26
  80. package/src/module/enterprise/entity/organization.entity.ts +3 -0
  81. package/src/module/enterprise/repository/school.repository.ts +44 -31
  82. package/src/module/enterprise/service/brand.service.ts +2 -1
  83. package/src/module/enterprise/service/organization.service.ts +63 -10
  84. package/src/module/filter/service/filter.service.ts +1 -1
  85. package/src/module/layout_preference/controller/layout_preference.controller.ts +2 -2
  86. package/src/module/layout_preference/entity/layout_preference.entity.ts +1 -1
  87. package/src/module/layout_preference/service/layout_preference.service.ts +0 -7
  88. package/src/module/lead/lead.module.ts +1 -5
  89. package/src/module/lead/repository/lead.repository.ts +19 -15
  90. package/src/module/meta/entity/brand-profile.entity.ts +5 -0
  91. package/src/module/meta/entity/field-group.entity.ts +20 -20
  92. package/src/module/meta/entity/section-master.entity.ts +22 -22
  93. package/src/module/meta/entity/user-app-mapping.entity.ts +16 -16
  94. package/src/module/meta/entity.module.ts +20 -18
  95. package/src/module/meta/repository/user-app-mapping.repository.ts +25 -26
  96. package/src/module/meta/service/user-app-mapping.service.ts +14 -14
  97. package/src/module/meta/service/view-master.service.ts +38 -38
  98. package/src/module/module/repository/menu.repository.ts +1 -1
  99. package/src/module/module/repository/module-access.repository.ts +23 -33
  100. package/src/module/module/service/module-access.service.ts +1 -1
  101. package/src/module/notification/entity/otp.entity.ts +3 -3
  102. package/src/module/third-party-module/entity/third-party-api-registry.entity.ts +2 -2
  103. package/src/module/user/service/login.service.ts +1 -1
  104. package/src/module/user/service/user-session.service.ts +1 -1
  105. package/src/module/user/service/user.service.ts +2 -2
  106. package/src/resources/dev.properties.yaml +3 -3
  107. package/src/utils/service/wbsCodeGen.service.ts +8 -0
  108. package/src/utils/utils.module.ts +15 -2
  109. package/dist/module/enterprise/entity/brand.entity.d.ts +0 -4
  110. package/dist/module/enterprise/entity/brand.entity.js.map +0 -1
  111. package/dist/module/enterprise/entity/school.entity.d.ts +0 -7
  112. package/dist/module/enterprise/entity/school.entity.js +0 -37
  113. package/dist/module/enterprise/entity/school.entity.js.map +0 -1
  114. package/dist/module/enterprise/repository/brand.repository.d.ts +0 -8
  115. package/dist/module/enterprise/repository/brand.repository.js +0 -39
  116. package/dist/module/enterprise/repository/brand.repository.js.map +0 -1
  117. package/dist/module/enterprise/service/school.service.d.ts +0 -3
  118. package/dist/module/enterprise/service/school.service.js.map +0 -1
  119. package/src/module/enterprise/entity/brand.entity.ts +0 -8
  120. package/src/module/enterprise/entity/school.entity.ts +0 -17
  121. package/src/module/enterprise/repository/brand.repository.ts +0 -23
  122. package/src/module/enterprise/service/school.service.ts +0 -5
@@ -0,0 +1,3 @@
1
+ export declare class WBSCodeGenService {
2
+ padCode(num: number): string;
3
+ }
@@ -6,13 +6,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.SchoolService = void 0;
9
+ exports.WBSCodeGenService = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
- const entity_service_impl_service_1 = require("../../meta/service/entity-service-impl.service");
12
- let SchoolService = class SchoolService extends entity_service_impl_service_1.EntityServiceImpl {
11
+ let WBSCodeGenService = class WBSCodeGenService {
12
+ padCode(num) {
13
+ return num.toString().padStart(5, '0');
14
+ }
13
15
  };
14
- exports.SchoolService = SchoolService;
15
- exports.SchoolService = SchoolService = __decorate([
16
+ exports.WBSCodeGenService = WBSCodeGenService;
17
+ exports.WBSCodeGenService = WBSCodeGenService = __decorate([
16
18
  (0, common_1.Injectable)()
17
- ], SchoolService);
18
- //# sourceMappingURL=school.service.js.map
19
+ ], WBSCodeGenService);
20
+ //# sourceMappingURL=wbsCodeGen.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wbsCodeGen.service.js","sourceRoot":"","sources":["../../../src/utils/service/wbsCodeGen.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AAG7C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,OAAO,CAAC,GAAW;QACjB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAJY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAI7B"}
@@ -12,14 +12,27 @@ const loggingUtil_service_1 = require("./service/loggingUtil.service");
12
12
  const reflection_helper_service_1 = require("./service/reflection-helper.service");
13
13
  const excelUtil_service_1 = require("./service/excelUtil.service");
14
14
  const clockIDGenUtil_service_1 = require("./service/clockIDGenUtil.service");
15
+ const wbsCodeGen_service_1 = require("./service/wbsCodeGen.service");
15
16
  let UtilsModule = class UtilsModule {
16
17
  };
17
18
  exports.UtilsModule = UtilsModule;
18
19
  exports.UtilsModule = UtilsModule = __decorate([
19
20
  (0, common_1.Global)(),
20
21
  (0, common_1.Module)({
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],
22
+ providers: [
23
+ loggingUtil_service_1.LoggingService,
24
+ reflection_helper_service_1.ReflectionHelper,
25
+ excelUtil_service_1.ExcelUtil,
26
+ clockIDGenUtil_service_1.ClockIDGenService,
27
+ wbsCodeGen_service_1.WBSCodeGenService,
28
+ ],
29
+ exports: [
30
+ loggingUtil_service_1.LoggingService,
31
+ reflection_helper_service_1.ReflectionHelper,
32
+ excelUtil_service_1.ExcelUtil,
33
+ clockIDGenUtil_service_1.ClockIDGenService,
34
+ wbsCodeGen_service_1.WBSCodeGenService,
35
+ ],
23
36
  })
24
37
  ], UtilsModule);
25
38
  //# 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,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"}
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;AACrE,qEAAiE;AAmB1D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAjBvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,oCAAc;YACd,4CAAgB;YAChB,6BAAS;YACT,0CAAiB;YACjB,sCAAiB;SAClB;QACD,OAAO,EAAE;YACP,oCAAc;YACd,4CAAgB;YAChB,6BAAS;YACT,0CAAiB;YACjB,sCAAiB;SAClB;KACF,CAAC;GACW,WAAW,CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.1.133",
3
+ "version": "2.2.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,9 +1,8 @@
1
1
  import { Controller, Get, Inject, Req, UseGuards } from '@nestjs/common';
2
- import { OrganizationService } from '../service/organization.service';
3
2
  import { Request } from 'express';
4
3
  import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
5
4
  import { UserService } from 'src/module/user/service/user.service';
6
- import { ENTITYTYPE_USER } from '../../../constant/global.constant';
5
+ import { OrganizationService } from '../service/organization.service';
7
6
 
8
7
  @Controller('organization')
9
8
  export class OrganizationController {
@@ -1,29 +1,19 @@
1
1
  import { forwardRef, Module } from '@nestjs/common';
2
2
  import { TypeOrmModule } from '@nestjs/typeorm';
3
- import { OrganizationService } from './service/organization.service';
4
- import { OrganizationData } from './entity/organization.entity';
5
- import { OrganizationController } from './controller/organization.controller';
6
3
  import { UserModule } from '../user/user.module';
7
- import { OrganizationAppMappingService } from './service/organization-app-mapping.service';
4
+ import { OrganizationController } from './controller/organization.controller';
8
5
  import { OrganizationAppMapping } from './entity/organization-app-mapping.entity';
9
- import { BrandData } from './entity/brand.entity';
10
- import { SchoolData } from './entity/school.entity';
11
- import { BrandRepository } from './repository/brand.repository';
12
- import { SchoolRepository } from './repository/school.repository';
6
+ import { OrganizationData } from './entity/organization.entity';
7
+ import { OrganizationAppMappingService } from './service/organization-app-mapping.service';
8
+ import { OrganizationService } from './service/organization.service';
13
9
  import { UtilsModule } from 'src/utils/utils.module';
14
- import { BrandService } from './service/brand.service';
15
- import { OrganizationRepository } from './repository/organization.repository';
16
- import { SchoolService } from './service/school.service';
17
10
  import { EntityModule } from '../meta/entity.module';
11
+ import { OrganizationRepository } from './repository/organization.repository';
12
+ import { SchoolRepository } from './repository/school.repository';
18
13
 
19
14
  @Module({
20
15
  imports: [
21
- TypeOrmModule.forFeature([
22
- OrganizationData,
23
- OrganizationAppMapping,
24
- BrandData,
25
- SchoolData,
26
- ]),
16
+ TypeOrmModule.forFeature([OrganizationData, OrganizationAppMapping]),
27
17
  forwardRef(() => UserModule),
28
18
  UtilsModule,
29
19
  EntityModule,
@@ -32,17 +22,8 @@ import { EntityModule } from '../meta/entity.module';
32
22
  providers: [
33
23
  OrganizationService,
34
24
  OrganizationAppMappingService,
35
- BrandRepository,
36
25
  SchoolRepository,
37
26
  OrganizationRepository,
38
- {
39
- provide: 'BrandService',
40
- useClass: BrandService,
41
- },
42
- {
43
- provide: 'SchoolService',
44
- useClass: SchoolService,
45
- },
46
27
  ],
47
28
  exports: [OrganizationService, OrganizationRepository],
48
29
  })
@@ -83,4 +83,7 @@ export class OrganizationData {
83
83
 
84
84
  @Column({ name: 'type', nullable: true })
85
85
  type: string;
86
+
87
+ @Column({ name: 'wbs_code', nullable: true })
88
+ wbs_code: string;
86
89
  }
@@ -1,27 +1,29 @@
1
1
  import { Injectable } from '@nestjs/common';
2
- import { InjectRepository } from '@nestjs/typeorm';
2
+ // import { InjectRepository } from '@nestjs/typeorm';
3
3
  import { DataSource, Repository } from 'typeorm';
4
- import { SchoolData } from '../entity/school.entity';
4
+ // import { SchoolData } from '../entity/school.entity';
5
5
  import { UserRoleMapping } from 'src/module/user/entity/user-role-mapping.entity';
6
6
 
7
7
  @Injectable()
8
8
  export class SchoolRepository {
9
- constructor(
10
- @InjectRepository(SchoolData)
11
- private readonly schoolRepo: Repository<SchoolData>,
12
- private readonly dataSource: DataSource,
13
- ) {}
14
-
15
- async findAllByOrgId(brdId: number): Promise<SchoolData[]> {
16
- return await this.schoolRepo.find({
17
- where: { brand_id: brdId },
18
- });
9
+ constructor(private readonly dataSource: DataSource) {}
10
+
11
+ async findAllByOrgId(orgId: number): Promise<any[]> {
12
+ return await this.dataSource
13
+ .createQueryBuilder()
14
+ .select(['*'])
15
+ .from('eth_school_profile', 'sch')
16
+ .where('sch.organization_id = :orgId', { orgId })
17
+ .getRawMany();
19
18
  }
20
19
 
21
- async findAllByBrandId(brdId: number): Promise<SchoolData[]> {
22
- return await this.schoolRepo.find({
23
- where: { brand_id: brdId },
24
- });
20
+ async findAllByBrandId(brdId: number): Promise<any[]> {
21
+ return await this.dataSource
22
+ .createQueryBuilder()
23
+ .select(['*'])
24
+ .from('eth_school_profile', 'sch')
25
+ .where('sch.brand_id = :brdId', { brdId })
26
+ .getRawMany();
25
27
  }
26
28
 
27
29
  async getUserContextDropdown(userId: number, appCode: string, org_id) {
@@ -34,6 +36,8 @@ export class SchoolRepository {
34
36
  .andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
35
37
  .getRawMany();
36
38
 
39
+ console.log('hasOrgAccess', hasOrgAccess);
40
+
37
41
  let currentORGLevel_id = hasOrgAccess[0]?.urm_level_id;
38
42
  if (hasOrgAccess[0]?.urm_level_id == 1) {
39
43
  currentORGLevel_id = org_id;
@@ -47,18 +51,27 @@ export class SchoolRepository {
47
51
  'org.name AS org_name',
48
52
  'org.address AS org_address',
49
53
  'org.status AS org_status',
50
- 'br.id AS brand_id',
51
- 'br.name AS brand_name',
52
- 'br.status AS brand_status',
53
- 'sch.id AS school_id',
54
- 'sch.name AS school_name',
55
- 'sch.location AS school_location',
56
- 'sch.status AS school_status',
54
+
55
+ 'brn.id AS brand_id',
56
+ 'brand_profile.name AS brand_name',
57
+ 'brand_profile.status AS brand_status',
58
+
59
+ 'school.id AS school_id',
60
+ 'school.name AS school_name',
61
+ 'school.location AS school_location',
62
+ 'school.status AS school_status',
57
63
  ])
58
- .from('cr_school', 'sch')
59
- .innerJoin('cr_brand', 'br', 'sch.brand_id = br.id')
60
- .innerJoin('cr_organization', 'org', 'br.organization_id = org.id')
61
- .where('org.id = :orgId', { orgId: currentORGLevel_id })
64
+ .from('cr_organization', 'org')
65
+ .innerJoin('cr_organization', 'brn', "brn.type = 'BRN'")
66
+ .innerJoin(
67
+ 'eth_brand_profile',
68
+ 'brand_profile',
69
+ 'brand_profile.parent_id = brn.id AND brand_profile.organization_id = org.id',
70
+ )
71
+ .innerJoin('eth_school_profile', 'school', 'school.brand_id = brn.id')
72
+ .where('org.id = :orgId', {
73
+ orgId: currentORGLevel_id,
74
+ })
62
75
  .getRawMany();
63
76
 
64
77
  if (schools.length > 0) {
@@ -175,8 +188,8 @@ export class SchoolRepository {
175
188
  'school.status AS school_status',
176
189
  ])
177
190
  .from('cr_user_role_mapping', 'urm')
178
- .innerJoin('cr_brand', 'brand', 'brand.id = urm.level_id')
179
- .innerJoin('cr_school', 'school', 'school.brand_id = brand.id')
191
+ .innerJoin('cr_organization', 'brand', 'brand.id = urm.level_id')
192
+ .innerJoin('eth_school_profile', 'school', 'school.brand_id = brand.id')
180
193
  .where('urm.user_id = :userId', { userId })
181
194
  .andWhere('urm.appcode = :appCode', { appCode })
182
195
  .andWhere('urm.level_type = :levelType', { levelType: 'BRN' })
@@ -194,8 +207,8 @@ export class SchoolRepository {
194
207
  'school.status AS school_status',
195
208
  ])
196
209
  .from('cr_user_role_mapping', 'urm')
197
- .innerJoin('cr_school', 'school', 'school.id = urm.level_id')
198
- .innerJoin('cr_brand', 'brand', 'brand.id = school.brand_id')
210
+ .innerJoin('eth_school_profile', 'school', 'school.id = urm.level_id')
211
+ .innerJoin('cr_organization', 'brand', 'brand.id = school.brand_id')
199
212
  .where('urm.user_id = :userId', { userId })
200
213
  .andWhere('urm.appcode = :appCode', { appCode })
201
214
  .andWhere('urm.level_type = :levelType', { levelType: 'SCH' })
@@ -1,4 +1,5 @@
1
1
  import { Injectable } from '@nestjs/common';
2
+ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
2
3
 
3
4
  @Injectable()
4
- export class BrandService {}
5
+ export class BrandService extends EntityServiceImpl {}
@@ -1,11 +1,10 @@
1
- import { Inject, Injectable } from '@nestjs/common';
1
+ import { Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { EntityManager, Repository } from 'typeorm';
4
- import { OrganizationData } from '../entity/organization.entity';
5
3
  import { ClockIDGenService } from 'src/utils/service/clockIDGenUtil.service';
6
- import { UserService } from 'src/module/user/service/user.service';
7
- import { ENTITYTYPE_USER } from 'src/constant/global.constant';
8
- import { BrandRepository } from '../repository/brand.repository';
4
+ import { EntityManager, IsNull, Repository } from 'typeorm';
5
+ import { OrganizationData } from '../entity/organization.entity';
6
+ // import { BrandRepository } from '../repository/brand.repository';
7
+ import { WBSCodeGenService } from 'src/utils/service/wbsCodeGen.service';
9
8
  import { SchoolRepository } from '../repository/school.repository';
10
9
 
11
10
  @Injectable()
@@ -13,10 +12,9 @@ export class OrganizationService {
13
12
  constructor(
14
13
  @InjectRepository(OrganizationData)
15
14
  private readonly organizationRepository: Repository<OrganizationData>,
16
- private readonly brandRepository: BrandRepository,
17
- private readonly schoolRepository: SchoolRepository,
18
15
  private readonly idGen: ClockIDGenService,
19
- @Inject('UserService') private readonly userService: UserService,
16
+ private readonly wbcCodeGenService: WBSCodeGenService,
17
+ private readonly schoolRepository: SchoolRepository,
20
18
  ) {}
21
19
 
22
20
  async create(
@@ -27,9 +25,64 @@ export class OrganizationService {
27
25
  ? manager.getRepository(OrganizationData)
28
26
  : this.organizationRepository;
29
27
 
28
+ const isBrand = organizationDto.type === 'BRN';
29
+
30
+ if (isBrand) {
31
+ // BRN case
32
+ const parentOrgId = organizationDto.parent_id;
33
+
34
+ if (!parentOrgId) {
35
+ throw new Error('Parent Org ID is required to create a brand.');
36
+ }
37
+
38
+ const parentOrg = await repo.findOne({
39
+ where: { id: parentOrgId },
40
+ });
41
+
42
+ if (!parentOrg) {
43
+ throw new Error('Parent organization not found.');
44
+ }
45
+
46
+ const existingBrands = await repo.find({
47
+ where: {
48
+ type: 'BRN',
49
+ parent_id: parentOrgId,
50
+ },
51
+ select: ['wbs_code'],
52
+ });
53
+
54
+ const brandCodes = existingBrands
55
+ .map((b) => b.wbs_code?.split('.')[1])
56
+ .filter(Boolean)
57
+ .map(Number);
58
+
59
+ const nextBrnCode = brandCodes.length ? Math.max(...brandCodes) + 1 : 1;
60
+
61
+ const brnWbsCode = this.wbcCodeGenService.padCode(nextBrnCode);
62
+ organizationDto.wbs_code = `${parentOrg.wbs_code}.${brnWbsCode}`;
63
+ } else {
64
+ // ORG case
65
+ const existingOrgs = await repo.find({
66
+ where: {
67
+ type: IsNull(),
68
+ },
69
+ select: ['wbs_code'],
70
+ });
71
+
72
+ const orgCodes = existingOrgs
73
+ .map((org) => org.wbs_code)
74
+ .filter(Boolean)
75
+ .map(Number);
76
+
77
+ const nextOrgCode = orgCodes.length ? Math.max(...orgCodes) + 1 : 1;
78
+
79
+ organizationDto.wbs_code = this.wbcCodeGenService.padCode(nextOrgCode);
80
+ }
81
+
30
82
  organizationDto.code = this.idGen.idGenerator('ORG');
31
- organizationDto.status = 'ACTIVE';
83
+ // organizationDto.status = 'ACTIVE';
32
84
  organizationDto.created_date = new Date();
85
+
33
86
  const organization = repo.create(organizationDto);
34
87
  return await repo.save(organization);
35
88
  }
@@ -163,7 +163,7 @@ export class FilterService {
163
163
  // layout preference query
164
164
  const layoutPreference = await this.dataSource.query(
165
165
  `SELECT layout_json
166
- FROM cr_layout_preference
166
+ FROM cr_entity_layout_pref
167
167
  WHERE user_id = ? AND mapped_entity_type = ?`,
168
168
  [user_id, entity_type],
169
169
  );
@@ -31,13 +31,13 @@ export class LayoutPreferenceController {
31
31
  @Query('sort_by') sort_by: string,
32
32
  @Req() req: Request & { user: any },
33
33
  ) {
34
- const loggedInUser = req.user.userData;
34
+ const userData = req.user.userData;
35
35
 
36
36
  return this.layoutPreferenceService.getColumnValue(
37
37
  entity_type,
38
38
  column,
39
39
  sort_by,
40
- loggedInUser,
40
+ userData,
41
41
  );
42
42
  }
43
43
  }
@@ -1,7 +1,7 @@
1
1
  import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
2
2
  import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
3
3
 
4
- @Entity({ name: 'cr_layout_preference' })
4
+ @Entity({ name: 'cr_entity_layout_pref' })
5
5
  export class LayoutPreference extends BaseEntity {
6
6
  @Column({ length: 50, nullable: true })
7
7
  user_id: string;
@@ -77,13 +77,6 @@ export class LayoutPreferenceService extends EntityServiceImpl {
77
77
  .addSelect(`COUNT(*) AS count`)
78
78
  .from(tableName, tableName)
79
79
  .where(`${column} IS NOT NULL`)
80
- .andWhere(`organization_id = :organizationId`, {
81
- organizationId: loggedInUser?.organization_id,
82
- })
83
- .andWhere(`level_id = :levelId`, { levelId: loggedInUser?.level_id })
84
- .andWhere(`level_type = :levelType`, {
85
- levelType: loggedInUser?.level_type,
86
- })
87
80
  .groupBy(column)
88
81
  .getRawMany();
89
82
 
@@ -4,13 +4,9 @@ import { LeadService } from './service/lead.service';
4
4
  import { LeadRepository } from './repository/lead.repository';
5
5
  import { TypeOrmModule } from '@nestjs/typeorm';
6
6
  import { OrganizationData } from '../enterprise/entity/organization.entity';
7
- import { BrandData } from '../enterprise/entity/brand.entity';
8
- import { SchoolData } from '../enterprise/entity/school.entity';
9
7
 
10
8
  @Module({
11
- imports: [
12
- TypeOrmModule.forFeature([OrganizationData, BrandData, SchoolData]),
13
- ],
9
+ imports: [TypeOrmModule.forFeature([OrganizationData])],
14
10
  providers: [LeadService, LeadRepository],
15
11
  controllers: [],
16
12
  exports: [LeadService],
@@ -1,37 +1,41 @@
1
1
  import { Injectable } from '@nestjs/common';
2
2
  import { InjectRepository } from '@nestjs/typeorm';
3
- import { BrandData } from 'src/module/enterprise/entity/brand.entity';
3
+ // import { BrandData } from 'src/module/enterprise/entity/brand.entity';
4
4
  import { OrganizationData } from 'src/module/enterprise/entity/organization.entity';
5
- import { SchoolData } from 'src/module/enterprise/entity/school.entity';
6
- import { Repository } from 'typeorm';
5
+ // import { SchoolData } from 'src/module/enterprise/entity/school.entity';
6
+ import { DataSource, Repository } from 'typeorm';
7
7
 
8
8
  @Injectable()
9
9
  export class LeadRepository {
10
10
  constructor(
11
11
  @InjectRepository(OrganizationData)
12
12
  private organizationRepository: Repository<OrganizationData>,
13
- @InjectRepository(BrandData)
14
- private brandRepository: Repository<BrandData>,
15
- @InjectRepository(SchoolData)
16
- private schoolRepository: Repository<SchoolData>,
13
+ private readonly dataSource: DataSource,
17
14
  ) {}
18
15
 
19
16
  async getAllOrganizations(): Promise<OrganizationData[]> {
20
17
  return this.organizationRepository.find();
21
18
  }
22
19
 
23
- async getBrandsByOrganization(organization_id: number): Promise<BrandData[]> {
24
- return this.brandRepository.find({
25
- where: { organization_id },
26
- });
20
+ async getBrandsByOrganization(organization_id: number): Promise<any[]> {
21
+ return await this.dataSource
22
+ .createQueryBuilder()
23
+ .select(['*'])
24
+ .from('eth_brand_profile', 'brd')
25
+ .where('brd.organization_id = :orgId', { orgId: organization_id })
26
+ .getRawMany();
27
27
  }
28
28
 
29
29
  async getSchoolsByBrandAndOrganization(
30
30
  brand_id: number,
31
31
  organization_id: number,
32
- ): Promise<SchoolData[]> {
33
- return this.schoolRepository.find({
34
- where: { brand_id, organization_id },
35
- });
32
+ ): Promise<any[]> {
33
+ return await this.dataSource
34
+ .createQueryBuilder()
35
+ .select(['*'])
36
+ .from('eth_school_profile', 'sch')
37
+ .where('sch.brand_id = :brdId', { brdId: brand_id })
38
+ .andWhere('sch.organization_id = :orgId', { orgId: organization_id })
39
+ .getRawMany();
36
40
  }
37
41
  }
@@ -0,0 +1,5 @@
1
+ import { Entity } from 'typeorm';
2
+ import { BaseEntity } from './base-entity.entity';
3
+
4
+ @Entity({ name: 'eth_brand_profile' })
5
+ export class BrandProfile extends BaseEntity {}
@@ -1,25 +1,25 @@
1
- import { ENTITYTYPE_FIELDMASTER } from 'src/constant/global.constant';
2
- import { BaseEntity } from './base-entity.entity';
3
- import { Column, Entity } from 'typeorm';
1
+ // import { ENTITYTYPE_FIELDMASTER } from 'src/constant/global.constant';
2
+ // import { BaseEntity } from './base-entity.entity';
3
+ // import { Column, Entity } from 'typeorm';
4
4
 
5
- @Entity({ name: 'cr_field_group' })
6
- export class FieldGroup extends BaseEntity {
7
- constructor() {
8
- super();
9
- this.entity_type = ENTITYTYPE_FIELDMASTER;
10
- }
11
- @Column({ length: 50, nullable: true })
12
- mapped_entity_type: string;
5
+ // @Entity({ name: 'cr_field_group' })
6
+ // export class FieldGroup extends BaseEntity {
7
+ // constructor() {
8
+ // super();
9
+ // this.entity_type = ENTITYTYPE_FIELDMASTER;
10
+ // }
11
+ // @Column({ length: 50, nullable: true })
12
+ // mapped_entity_type: string;
13
13
 
14
- @Column({ length: 50, nullable: true })
15
- field_type: string;
14
+ // @Column({ length: 50, nullable: true })
15
+ // field_type: string;
16
16
 
17
- @Column({ nullable: true })
18
- description: string;
17
+ // @Column({ nullable: true })
18
+ // description: string;
19
19
 
20
- @Column({ type: 'varchar', nullable: true })
21
- label: string;
20
+ // @Column({ type: 'varchar', nullable: true })
21
+ // label: string;
22
22
 
23
- @Column({ type: 'int', nullable: true })
24
- view_id: number;
25
- }
23
+ // @Column({ type: 'int', nullable: true })
24
+ // view_id: number;
25
+ // }
@@ -1,28 +1,28 @@
1
- import { ENTITYTYPE_SECTIONMASTER } from 'src/constant/global.constant';
2
- import { BaseEntity } from './base-entity.entity';
3
- import { Column, Entity } from 'typeorm';
1
+ // import { ENTITYTYPE_SECTIONMASTER } from 'src/constant/global.constant';
2
+ // import { BaseEntity } from './base-entity.entity';
3
+ // import { Column, Entity } from 'typeorm';
4
4
 
5
- @Entity({ name: 'cr_section_master' })
6
- export class SectionMaster extends BaseEntity {
7
- constructor() {
8
- super();
9
- this.entity_type = ENTITYTYPE_SECTIONMASTER;
10
- }
11
- @Column({ length: 50, nullable: true })
12
- mapped_entity_type: string;
5
+ // @Entity({ name: 'cr_section_master' })
6
+ // export class SectionMaster extends BaseEntity {
7
+ // constructor() {
8
+ // super();
9
+ // this.entity_type = ENTITYTYPE_SECTIONMASTER;
10
+ // }
11
+ // @Column({ length: 50, nullable: true })
12
+ // mapped_entity_type: string;
13
13
 
14
- @Column({ length: 50, nullable: true })
15
- section_type: string;
14
+ // @Column({ length: 50, nullable: true })
15
+ // section_type: string;
16
16
 
17
- @Column({ nullable: true })
18
- description: string;
17
+ // @Column({ nullable: true })
18
+ // description: string;
19
19
 
20
- @Column({ type: 'varchar', nullable: true })
21
- tooltip: string;
20
+ // @Column({ type: 'varchar', nullable: true })
21
+ // tooltip: string;
22
22
 
23
- @Column({ type: 'int', nullable: true })
24
- visible_in_add: number;
23
+ // @Column({ type: 'int', nullable: true })
24
+ // visible_in_add: number;
25
25
 
26
- @Column({ type: 'int', nullable: true })
27
- position: number;
28
- }
26
+ // @Column({ type: 'int', nullable: true })
27
+ // position: number;
28
+ // }
@@ -1,21 +1,21 @@
1
- import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
1
+ // import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
2
 
3
- @Entity({ name: 'cr_user_app_mapping' })
4
- export class UserAppMapping {
5
- constructor(user_id: number) {
6
- this.user_id = user_id;
7
- this.entity_type = 'UAP';
8
- }
3
+ // @Entity({ name: 'cr_user_app_mapping' })
4
+ // export class UserAppMapping {
5
+ // constructor(user_id: number) {
6
+ // this.user_id = user_id;
7
+ // this.entity_type = 'UAP';
8
+ // }
9
9
 
10
- @PrimaryGeneratedColumn()
11
- id: number;
10
+ // @PrimaryGeneratedColumn()
11
+ // id: number;
12
12
 
13
- @Column({ type: 'bigint', nullable: true })
14
- user_id: number;
13
+ // @Column({ type: 'bigint', nullable: true })
14
+ // user_id: number;
15
15
 
16
- @Column({ type: 'varchar', nullable: true })
17
- appcode: string;
16
+ // @Column({ type: 'varchar', nullable: true })
17
+ // appcode: string;
18
18
 
19
- @Column({ type: 'varchar' })
20
- entity_type: string;
21
- }
19
+ // @Column({ type: 'varchar' })
20
+ // entity_type: string;
21
+ // }