import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; // import { BrandData } from 'src/module/enterprise/entity/brand.entity'; import { OrganizationData } from 'src/module/enterprise/entity/organization.entity'; // import { SchoolData } from 'src/module/enterprise/entity/school.entity'; import { DataSource, Repository } from 'typeorm'; @Injectable() export class LeadRepository { constructor( @InjectRepository(OrganizationData) private organizationRepository: Repository, private readonly dataSource: DataSource, ) {} async getAllOrganizations(): Promise { return this.organizationRepository.find(); } async getBrandsByOrganization(organization_id: number): Promise { return await this.dataSource .createQueryBuilder() .select(['*']) .from('eth_brand_profile', 'brd') .where('brd.organization_id = :orgId', { orgId: organization_id }) .getRawMany(); } async getSchoolsByBrandAndOrganization( brand_id: number, organization_id: number, ): Promise { return await this.dataSource .createQueryBuilder() .select(['*']) .from('sso_school', 'sch') .where('sch.brand_id = :brdId', { brdId: brand_id }) .andWhere('sch.organization_id = :orgId', { orgId: organization_id }) .getRawMany(); } }