league service

This commit is contained in:
2025-12-16 00:57:31 +01:00
parent 3b566c973d
commit 775d41e055
130 changed files with 4077 additions and 1036 deletions

View File

@@ -0,0 +1,23 @@
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
import type { IGetLeagueOwnerSummaryPresenter, GetLeagueOwnerSummaryResultDTO, GetLeagueOwnerSummaryViewModel } from '../presenters/IGetLeagueOwnerSummaryPresenter';
import type { UseCase } from '@gridpilot/shared/application/UseCase';
export interface GetLeagueOwnerSummaryUseCaseParams {
ownerId: string;
}
export interface GetLeagueOwnerSummaryResultDTO {
summary: { driver: { id: string; name: string }; rating: number; rank: number } | null;
}
export class GetLeagueOwnerSummaryUseCase implements UseCase<GetLeagueOwnerSummaryUseCaseParams, GetLeagueOwnerSummaryResultDTO, GetLeagueOwnerSummaryViewModel, IGetLeagueOwnerSummaryPresenter> {
constructor(private readonly driverRepository: IDriverRepository) {}
async execute(params: GetLeagueOwnerSummaryUseCaseParams, presenter: IGetLeagueOwnerSummaryPresenter): Promise<void> {
const driver = await this.driverRepository.findById(params.ownerId);
const summary = driver ? { driver: { id: driver.id, name: driver.name }, rating: 0, rank: 0 } : null;
const dto: GetLeagueOwnerSummaryResultDTO = { summary };
presenter.reset();
presenter.present(dto);
}
}