mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
33 lines
962 B
TypeScript
33 lines
962 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { BaseRepository } from '@edr/api-common';
|
|
import { FFClient } from './entities/ff-client.entity';
|
|
|
|
@Injectable()
|
|
export class FFClientRepository extends BaseRepository<FFClient> {
|
|
constructor(
|
|
@InjectRepository(FFClient)
|
|
repo: Repository<FFClient>,
|
|
) {
|
|
super(repo);
|
|
}
|
|
|
|
async findByForwarder(forwarderCompanyId: string): Promise<FFClient[]> {
|
|
return this.repository.find({ where: { forwarderCompanyId } as any });
|
|
}
|
|
|
|
async findByClient(clientCompanyId: string): Promise<FFClient[]> {
|
|
return this.repository.find({ where: { clientCompanyId } as any });
|
|
}
|
|
|
|
async findRelationship(
|
|
forwarderCompanyId: string,
|
|
clientCompanyId: string,
|
|
): Promise<FFClient | null> {
|
|
return this.repository.findOne({
|
|
where: { forwarderCompanyId, clientCompanyId } as any,
|
|
});
|
|
}
|
|
}
|