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

@@ -8,7 +8,6 @@ import type { IPaymentRepository } from '../../domain/repositories/IPaymentRepos
import type { Payment, PaymentType, PayerType } from '../../domain/entities/Payment';
import { PaymentStatus } from '../../domain/entities/Payment';
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';
@@ -28,14 +27,13 @@ export interface CreatePaymentResult {
export type CreatePaymentErrorCode = never;
export class CreatePaymentUseCase
implements UseCase<CreatePaymentInput, void, CreatePaymentErrorCode>
implements UseCase<CreatePaymentInput, CreatePaymentResult, CreatePaymentErrorCode>
{
constructor(
private readonly paymentRepository: IPaymentRepository,
private readonly output: UseCaseOutputPort<CreatePaymentResult>,
) {}
async execute(input: CreatePaymentInput): Promise<Result<void, ApplicationErrorCode<CreatePaymentErrorCode>>> {
async execute(input: CreatePaymentInput): Promise<Result<CreatePaymentResult, ApplicationErrorCode<CreatePaymentErrorCode>>> {
const { type, amount, payerId, payerType, leagueId, seasonId } = input;
// Calculate platform fee (assume 5% for now)
@@ -59,8 +57,6 @@ export class CreatePaymentUseCase
const createdPayment = await this.paymentRepository.create(payment);
this.output.present({ payment: createdPayment });
return Result.ok(undefined);
return Result.ok({ payment: createdPayment });
}
}