16 lines
652 B
TypeScript
16 lines
652 B
TypeScript
import { IOrganizationRepository } from '../../../Domain/IRepository/IOrganizationRepository';
|
|
import { GetOrganizationByIdQuery } from './GetOrganizationByIdQuery';
|
|
|
|
import { ShortOrganizationDto } from '../../DTOs/OrganizationDto';
|
|
import { OrganizationMapper } from '../../DTOs/Mappers/OrganizationMapper';
|
|
|
|
export class GetOrganizationByIdQueryHandler {
|
|
constructor(private readonly orgRepo: IOrganizationRepository) {}
|
|
|
|
async execute(query: GetOrganizationByIdQuery): Promise<ShortOrganizationDto | null> {
|
|
const org = await this.orgRepo.findById(query.id);
|
|
if (!org) return null;
|
|
return OrganizationMapper.toShortDto(org);
|
|
}
|
|
}
|