refactor use cases
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository';
|
||||
import type { ITransactionRepository } from '../../domain/repositories/ITransactionRepository';
|
||||
@@ -35,19 +35,16 @@ export type WithdrawFromLeagueWalletErrorCode =
|
||||
* Use Case for withdrawing from league wallet.
|
||||
*/
|
||||
export class WithdrawFromLeagueWalletUseCase {
|
||||
constructor(
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
constructor(private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly walletRepository: ILeagueWalletRepository,
|
||||
private readonly transactionRepository: ITransactionRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<WithdrawFromLeagueWalletResult>,
|
||||
) {}
|
||||
private readonly logger: Logger) {}
|
||||
|
||||
async execute(
|
||||
input: WithdrawFromLeagueWalletInput,
|
||||
): Promise<
|
||||
Result<
|
||||
void,
|
||||
WithdrawFromLeagueWalletResult,
|
||||
ApplicationErrorCode<
|
||||
WithdrawFromLeagueWalletErrorCode,
|
||||
{
|
||||
@@ -115,9 +112,7 @@ export class WithdrawFromLeagueWalletUseCase {
|
||||
walletBalanceAfter: updatedWallet.balance,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
'Failed to withdraw from league wallet',
|
||||
|
||||
Reference in New Issue
Block a user