league service
This commit is contained in:
23
core/racing/application/use-cases/GetTotalDriversUseCase.ts
Normal file
23
core/racing/application/use-cases/GetTotalDriversUseCase.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { ITotalDriversPresenter, TotalDriversResultDTO } from '../presenters/ITotalDriversPresenter';
|
||||
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
||||
|
||||
/**
|
||||
* Use Case for retrieving total number of drivers.
|
||||
*/
|
||||
export class GetTotalDriversUseCase
|
||||
implements UseCase<void, TotalDriversResultDTO, any, ITotalDriversPresenter>
|
||||
{
|
||||
constructor(private readonly driverRepository: IDriverRepository) {}
|
||||
|
||||
async execute(_input: void, presenter: ITotalDriversPresenter): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
const drivers = await this.driverRepository.findAll();
|
||||
const dto: TotalDriversResultDTO = {
|
||||
totalDrivers: drivers.length,
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user