wip
This commit is contained in:
@@ -1,22 +1,30 @@
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import type { IAllLeaguesWithCapacityPresenter } from '../presenters/IAllLeaguesWithCapacityPresenter';
|
||||
import type { AsyncUseCase } from '@gridpilot/shared/application';
|
||||
import type {
|
||||
IAllLeaguesWithCapacityPresenter,
|
||||
AllLeaguesWithCapacityResultDTO,
|
||||
AllLeaguesWithCapacityViewModel,
|
||||
} from '../presenters/IAllLeaguesWithCapacityPresenter';
|
||||
import type { UseCase } from '@gridpilot/shared/application/UseCase';
|
||||
|
||||
/**
|
||||
* Use Case for retrieving all leagues with capacity information.
|
||||
* Orchestrates domain logic and delegates presentation to the presenter.
|
||||
*/
|
||||
export class GetAllLeaguesWithCapacityUseCase
|
||||
implements AsyncUseCase<void, void>
|
||||
implements UseCase<void, AllLeaguesWithCapacityResultDTO, AllLeaguesWithCapacityViewModel, IAllLeaguesWithCapacityPresenter>
|
||||
{
|
||||
constructor(
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
public readonly presenter: IAllLeaguesWithCapacityPresenter,
|
||||
) {}
|
||||
|
||||
async execute(): Promise<void> {
|
||||
async execute(
|
||||
_input: void,
|
||||
presenter: IAllLeaguesWithCapacityPresenter,
|
||||
): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
const leagues = await this.leagueRepository.findAll();
|
||||
|
||||
const memberCounts = new Map<string, number>();
|
||||
@@ -36,6 +44,11 @@ export class GetAllLeaguesWithCapacityUseCase
|
||||
memberCounts.set(league.id, usedSlots);
|
||||
}
|
||||
|
||||
this.presenter.present(leagues, memberCounts);
|
||||
const dto: AllLeaguesWithCapacityResultDTO = {
|
||||
leagues,
|
||||
memberCounts,
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user