2022-12-14 14:08:01 +00:00
|
|
|
import { QueryHandler } from '@nestjs/cqrs';
|
2023-05-05 14:56:30 +00:00
|
|
|
import { ICollection } from 'src/modules/database/interfaces/collection.interface';
|
2022-12-14 14:08:01 +00:00
|
|
|
import { UsersRepository } from '../../adapters/secondaries/users.repository';
|
|
|
|
import { FindAllUsersQuery } from '../../queries/find-all-users.query';
|
|
|
|
import { User } from '../entities/user';
|
|
|
|
|
|
|
|
@QueryHandler(FindAllUsersQuery)
|
|
|
|
export class FindAllUsersUseCase {
|
2023-05-05 14:56:30 +00:00
|
|
|
constructor(private readonly repository: UsersRepository) {}
|
2022-12-14 14:08:01 +00:00
|
|
|
|
2023-05-05 14:56:30 +00:00
|
|
|
execute = async (
|
2022-12-14 14:08:01 +00:00
|
|
|
findAllUsersQuery: FindAllUsersQuery,
|
2023-05-05 14:56:30 +00:00
|
|
|
): Promise<ICollection<User>> =>
|
|
|
|
this.repository.findAll(findAllUsersQuery.page, findAllUsersQuery.perPage);
|
2022-12-14 14:08:01 +00:00
|
|
|
}
|