Files
SerpentRace/SerpentRace_Backend/src/Application/Contact/queries/GetContactsByPageQueryHandler.ts
T

19 lines
708 B
TypeScript

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<ContactPageDto> {
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,
};
}
}