import { IContactRepository } from '../../../Domain/IRepository/IContactRepository'; import { GetContactsByPageQuery } from './GetContactsByPageQuery'; import { ContactPageDto } from '../../DTOs/ContactDto'; import { ContactMapper } from '../../DTOs/Mappers/ContactMapper'; export class GetContactsByPageQueryHandler { constructor(private readonly contactRepo: IContactRepository) {} async execute(query: GetContactsByPageQuery): Promise { const result = await this.contactRepo.findByPage(query.from, query.to); return { contacts: ContactMapper.toShortDtoList(result.contacts), totalCount: result.totalCount, from: query.from, to: query.to, }; } }