19 lines
1.0 KiB
TypeScript
19 lines
1.0 KiB
TypeScript
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
|
import type { AsyncUseCase } from '@core/shared/application';
|
|
import { Result } from '@core/shared/application/Result';
|
|
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
|
import type { GetLeagueOwnerSummaryResultDTO } from '../dto/GetLeagueOwnerSummaryResultDTO';
|
|
|
|
export interface GetLeagueOwnerSummaryUseCaseParams {
|
|
ownerId: string;
|
|
}
|
|
|
|
export class GetLeagueOwnerSummaryUseCase implements AsyncUseCase<GetLeagueOwnerSummaryUseCaseParams, GetLeagueOwnerSummaryResultDTO, 'NO_ERROR'> {
|
|
constructor(private readonly driverRepository: IDriverRepository) {}
|
|
|
|
async execute(params: GetLeagueOwnerSummaryUseCaseParams): Promise<Result<GetLeagueOwnerSummaryResultDTO, ApplicationErrorCode<'NO_ERROR'>>> {
|
|
const driver = await this.driverRepository.findById(params.ownerId);
|
|
const summary = driver ? { driver: { id: driver.id, name: driver.name }, rating: 0, rank: 0 } : null;
|
|
return Result.ok({ summary });
|
|
}
|
|
} |