refactor core presenters

This commit is contained in:
2025-12-19 19:42:19 +01:00
parent 8116fe888f
commit 94fc538f44
228 changed files with 2817 additions and 3097 deletions

View File

@@ -1,5 +1,5 @@
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
import type { GetLeagueSeasonsViewModel } from '../presenters/IGetLeagueSeasonsPresenter';
import type { GetLeagueSeasonsOutputPort } from '../ports/output/GetLeagueSeasonsOutputPort';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
@@ -10,11 +10,11 @@ export interface GetLeagueSeasonsUseCaseParams {
export class GetLeagueSeasonsUseCase {
constructor(private readonly seasonRepository: ISeasonRepository) {}
async execute(params: GetLeagueSeasonsUseCaseParams): Promise<Result<GetLeagueSeasonsViewModel, ApplicationErrorCode<'REPOSITORY_ERROR', { message: string }>>> {
async execute(params: GetLeagueSeasonsUseCaseParams): Promise<Result<GetLeagueSeasonsOutputPort, ApplicationErrorCode<'REPOSITORY_ERROR', { message: string }>>> {
try {
const seasons = await this.seasonRepository.findByLeagueId(params.leagueId);
const activeCount = seasons.filter(s => s.status === 'active').length;
const viewModel: GetLeagueSeasonsViewModel = {
const output: GetLeagueSeasonsOutputPort = {
seasons: seasons.map(s => ({
seasonId: s.id,
name: s.name,
@@ -25,7 +25,7 @@ export class GetLeagueSeasonsUseCase {
isParallelActive: s.status === 'active' && activeCount > 1
}))
};
return Result.ok(viewModel);
return Result.ok(output);
} catch {
return Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'Failed to fetch seasons' } });
}