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

@@ -7,7 +7,6 @@
import type { IWalletRepository, ITransactionRepository } from '../../domain/repositories/IWalletRepository';
import type { Wallet, Transaction } from '../../domain/entities/Wallet';
import type { UseCase } from '@core/shared/application/UseCase';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
@@ -23,15 +22,14 @@ export interface GetWalletResult {
}
export class GetWalletUseCase
implements UseCase<GetWalletInput, void, GetWalletErrorCode>
implements UseCase<GetWalletInput, GetWalletResult, GetWalletErrorCode>
{
constructor(
private readonly walletRepository: IWalletRepository,
private readonly transactionRepository: ITransactionRepository,
private readonly output: UseCaseOutputPort<GetWalletResult>,
) {}
async execute(input: GetWalletInput): Promise<Result<void, ApplicationErrorCode<GetWalletErrorCode>>> {
async execute(input: GetWalletInput): Promise<Result<GetWalletResult, ApplicationErrorCode<GetWalletErrorCode>>> {
const { leagueId } = input;
if (!leagueId) {
@@ -58,8 +56,6 @@ export class GetWalletUseCase
const transactions = await this.transactionRepository.findByWalletId(wallet.id);
transactions.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
this.output.present({ wallet, transactions });
return Result.ok(undefined);
return Result.ok({ wallet, transactions });
}
}