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,6 +1,6 @@
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
import type { AllLeaguesWithCapacityResultDTO } from '../presenters/IAllLeaguesWithCapacityPresenter';
import type { AllLeaguesWithCapacityOutputPort } from '../ports/output/AllLeaguesWithCapacityOutputPort';
import type { AsyncUseCase } from '@core/shared/application';
import { Result } from '@/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
@@ -10,17 +10,17 @@ import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorC
* Orchestrates domain logic and returns result.
*/
export class GetAllLeaguesWithCapacityUseCase
implements AsyncUseCase<void, AllLeaguesWithCapacityResultDTO, string>
implements AsyncUseCase<void, AllLeaguesWithCapacityOutputPort, string>
{
constructor(
private readonly leagueRepository: ILeagueRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
) {}
async execute(): Promise<Result<AllLeaguesWithCapacityResultDTO, ApplicationErrorCode<string>>> {
async execute(): Promise<Result<AllLeaguesWithCapacityOutputPort, ApplicationErrorCode<string>>> {
const leagues = await this.leagueRepository.findAll();
const memberCounts = new Map<string, number>();
const memberCounts: Record<string, number> = {};
for (const league of leagues) {
const members = await this.leagueMembershipRepository.getLeagueMembers(league.id);
@@ -34,14 +34,14 @@ export class GetAllLeaguesWithCapacityUseCase
m.role === 'member'),
).length;
memberCounts.set(league.id, usedSlots);
memberCounts[league.id] = usedSlots;
}
const dto: AllLeaguesWithCapacityResultDTO = {
const output: AllLeaguesWithCapacityOutputPort = {
leagues,
memberCounts,
};
return Result.ok(dto);
return Result.ok(output);
}
}