refactor use cases
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user