This commit is contained in:
2025-12-16 21:05:01 +01:00
parent f61e3a4e5a
commit 7532c7ed6d
207 changed files with 7861 additions and 2606 deletions

View File

@@ -7,27 +7,22 @@
import type { IProtestRepository } from '../../domain/repositories/IProtestRepository';
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
import type {
IRaceProtestsPresenter,
RaceProtestsResultDTO,
RaceProtestsViewModel,
} from '../presenters/IRaceProtestsPresenter';
import type { UseCase } from '@core/shared/application/UseCase';
import type { RaceProtestsResultDTO } from '../presenters/IRaceProtestsPresenter';
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
export interface GetRaceProtestsInput {
raceId: string;
}
export class GetRaceProtestsUseCase
implements
UseCase<GetRaceProtestsInput, RaceProtestsResultDTO, RaceProtestsViewModel, IRaceProtestsPresenter>
{
export class GetRaceProtestsUseCase implements AsyncUseCase<GetRaceProtestsInput, RaceProtestsResultDTO, 'NO_ERROR'> {
constructor(
private readonly protestRepository: IProtestRepository,
private readonly driverRepository: IDriverRepository,
) {}
async execute(input: GetRaceProtestsInput, presenter: IRaceProtestsPresenter): Promise<void> {
async execute(input: GetRaceProtestsInput): Promise<Result<RaceProtestsResultDTO, ApplicationErrorCode<'NO_ERROR'>>> {
const protests = await this.protestRepository.findByRaceId(input.raceId);
const driverIds = new Set<string>();
@@ -50,11 +45,10 @@ export class GetRaceProtestsUseCase
}
});
presenter.reset();
const dto: RaceProtestsResultDTO = {
protests,
driverMap,
};
presenter.present(dto);
return Result.ok(dto);
}
}