refactor
This commit is contained in:
@@ -1,30 +1,23 @@
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import type {
|
||||
IAllLeaguesWithCapacityPresenter,
|
||||
AllLeaguesWithCapacityResultDTO,
|
||||
AllLeaguesWithCapacityViewModel,
|
||||
} from '../presenters/IAllLeaguesWithCapacityPresenter';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import type { AllLeaguesWithCapacityResultDTO } from '../presenters/IAllLeaguesWithCapacityPresenter';
|
||||
import type { AsyncUseCase } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/result/Result';
|
||||
import { RacingDomainValidationError } from '../../domain/errors/RacingDomainError';
|
||||
|
||||
/**
|
||||
* Use Case for retrieving all leagues with capacity information.
|
||||
* Orchestrates domain logic and delegates presentation to the presenter.
|
||||
* Orchestrates domain logic and returns result.
|
||||
*/
|
||||
export class GetAllLeaguesWithCapacityUseCase
|
||||
implements UseCase<void, AllLeaguesWithCapacityResultDTO, AllLeaguesWithCapacityViewModel, IAllLeaguesWithCapacityPresenter>
|
||||
implements AsyncUseCase<void, Result<AllLeaguesWithCapacityResultDTO, RacingDomainValidationError>>
|
||||
{
|
||||
constructor(
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
_input: void,
|
||||
presenter: IAllLeaguesWithCapacityPresenter,
|
||||
): Promise<void> {
|
||||
presenter.reset();
|
||||
|
||||
async execute(): Promise<Result<AllLeaguesWithCapacityResultDTO, RacingDomainValidationError>> {
|
||||
const leagues = await this.leagueRepository.findAll();
|
||||
|
||||
const memberCounts = new Map<string, number>();
|
||||
@@ -49,6 +42,6 @@ export class GetAllLeaguesWithCapacityUseCase
|
||||
memberCounts,
|
||||
};
|
||||
|
||||
presenter.present(dto);
|
||||
return Result.ok(dto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user