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