user/.old/domain/usecases/find-all-users.usecase.ts

16 lines
633 B
TypeScript

import { QueryHandler } from '@nestjs/cqrs';
import { ICollection } from 'src/modules/database/interfaces/collection.interface';
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 {
constructor(private readonly repository: UsersRepository) {}
execute = async (
findAllUsersQuery: FindAllUsersQuery,
): Promise<ICollection<User>> =>
this.repository.findAll(findAllUsersQuery.page, findAllUsersQuery.perPage);
}