refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -3,7 +3,6 @@ import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueW
import type { ITransactionRepository } from '../../domain/repositories/ITransactionRepository';
import type { Transaction } from '../../domain/entities/league-wallet/Transaction';
import type { LeagueWallet } from '../../domain/entities/league-wallet/LeagueWallet';
import type { UseCaseOutputPort } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { Money } from '../../domain/value-objects/Money';
@@ -39,13 +38,12 @@ export class GetLeagueWalletUseCase {
private readonly leagueRepository: ILeagueRepository,
private readonly leagueWalletRepository: ILeagueWalletRepository,
private readonly transactionRepository: ITransactionRepository,
private readonly output: UseCaseOutputPort<GetLeagueWalletResult>,
) {}
async execute(
input: GetLeagueWalletInput,
): Promise<
Result<void, ApplicationErrorCode<GetLeagueWalletErrorCode, { message: string }>>
Result<GetLeagueWalletResult, ApplicationErrorCode<GetLeagueWalletErrorCode, { message: string }>>
> {
try {
const leagueExists = await this.leagueRepository.exists(input.leagueId);
@@ -79,9 +77,7 @@ export class GetLeagueWalletUseCase {
aggregates,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',