rez_core 2.0.49 → 2.0.50

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.0.49",
3
+ "version": "2.0.50",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
package/src/app.module.ts CHANGED
@@ -10,6 +10,8 @@ import Properties from './resources/properties.module';
10
10
  import { LayoutModule } from './module/layout/layout.module';
11
11
  import { ListMasterModule } from './module/listmaster/listmaster.module';
12
12
  import { ThirdPartyModule } from './module/third-party-module/third-party.module';
13
+ import { FilterModule } from './module/filter/filter.module';
14
+ import { LeadModule } from './module/lead/lead.module';
13
15
 
14
16
  @Module({
15
17
  imports: [
@@ -24,6 +26,8 @@ import { ThirdPartyModule } from './module/third-party-module/third-party.module
24
26
  LayoutModule,
25
27
  ListMasterModule,
26
28
  ThirdPartyModule,
29
+ FilterModule,
30
+ LeadModule,
27
31
  ],
28
32
  })
29
33
  export class AppModule {}
@@ -0,0 +1,30 @@
1
+ import { Controller, Get, Param, Query } from '@nestjs/common';
2
+ import { LeadService } from '../service/lead.service';
3
+
4
+ @Controller('lead')
5
+ export class LeadController {
6
+ constructor(private readonly leadService: LeadService) {}
7
+
8
+ @Get('organizations')
9
+ async getAllOrganizations() {
10
+ return this.leadService.getAllOrganizations();
11
+ }
12
+
13
+ @Get('brands/:organizationId')
14
+ async getBrandsByOrganization(
15
+ @Param('organizationId') organizationId: number,
16
+ ) {
17
+ return this.leadService.getBrandsByOrganization(organizationId);
18
+ }
19
+
20
+ @Get('schools')
21
+ async getSchoolsByBrandAndOrganization(
22
+ @Query('brandId') brandId: number,
23
+ @Query('organizationId') organizationId: number,
24
+ ) {
25
+ return this.leadService.getSchoolsByBrandAndOrganization(
26
+ brandId,
27
+ organizationId,
28
+ );
29
+ }
30
+ }
@@ -0,0 +1,18 @@
1
+ import { Module } from '@nestjs/common';
2
+ import { LeadController } from './controller/lead.controller';
3
+ import { LeadService } from './service/lead.service';
4
+ import { LeadRepository } from './repository/lead.repository';
5
+ import { TypeOrmModule } from '@nestjs/typeorm';
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
+
10
+ @Module({
11
+ imports: [
12
+ TypeOrmModule.forFeature([OrganizationData, BrandData, SchoolData]),
13
+ ],
14
+ providers: [LeadService, LeadRepository],
15
+ controllers: [LeadController],
16
+ exports: [],
17
+ })
18
+ export class LeadModule {}
@@ -0,0 +1,37 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { InjectRepository } from '@nestjs/typeorm';
3
+ import { BrandData } from 'src/module/enterprise/entity/brand.entity';
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';
7
+
8
+ @Injectable()
9
+ export class LeadRepository {
10
+ constructor(
11
+ @InjectRepository(OrganizationData)
12
+ private organizationRepository: Repository<OrganizationData>,
13
+ @InjectRepository(BrandData)
14
+ private brandRepository: Repository<BrandData>,
15
+ @InjectRepository(SchoolData)
16
+ private schoolRepository: Repository<SchoolData>,
17
+ ) {}
18
+
19
+ async getAllOrganizations(): Promise<OrganizationData[]> {
20
+ return this.organizationRepository.find();
21
+ }
22
+
23
+ async getBrandsByOrganization(organization_id: number): Promise<BrandData[]> {
24
+ return this.brandRepository.find({
25
+ where: { organization_id },
26
+ });
27
+ }
28
+
29
+ async getSchoolsByBrandAndOrganization(
30
+ brand_id: number,
31
+ organization_id: number,
32
+ ): Promise<SchoolData[]> {
33
+ return this.schoolRepository.find({
34
+ where: { brand_id, organization_id },
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,54 @@
1
+ import { Injectable, NotFoundException } from '@nestjs/common';
2
+ import { LeadRepository } from '../repository/lead.repository';
3
+
4
+ @Injectable()
5
+ export class LeadService {
6
+ constructor(private readonly leadRepository: LeadRepository) {}
7
+
8
+ async getAllOrganizations() {
9
+ const organizations = await this.leadRepository.getAllOrganizations();
10
+ return organizations.map((org) => ({
11
+ id: org.id,
12
+ name: org.name,
13
+ // Add other organization fields as needed
14
+ }));
15
+ }
16
+
17
+ async getBrandsByOrganization(organizationId: number) {
18
+ const brands =
19
+ await this.leadRepository.getBrandsByOrganization(organizationId);
20
+ if (!brands.length) {
21
+ throw new NotFoundException(
22
+ `No brands found for organization ID ${organizationId}`,
23
+ );
24
+ }
25
+ return brands.map((brand) => ({
26
+ id: brand.id,
27
+ name: brand.name,
28
+ organizationId: brand.organization_id,
29
+ // Add other brand fields as needed
30
+ }));
31
+ }
32
+
33
+ async getSchoolsByBrandAndOrganization(
34
+ brandId: number,
35
+ organizationId: number,
36
+ ) {
37
+ const schools = await this.leadRepository.getSchoolsByBrandAndOrganization(
38
+ brandId,
39
+ organizationId,
40
+ );
41
+ if (!schools.length) {
42
+ throw new NotFoundException(
43
+ `No schools found for brand ID ${brandId} and organization ID ${organizationId}`,
44
+ );
45
+ }
46
+ return schools.map((school) => ({
47
+ id: school.id,
48
+ name: school.name,
49
+ brandId: school.brand_id,
50
+ organizationId: school.organization_id,
51
+ // Add other school fields as needed
52
+ }));
53
+ }
54
+ }