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 } 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';
@@ -24,14 +23,13 @@ export interface UpdatePaymentStatusResult {
}
export class UpdatePaymentStatusUseCase
implements UseCase<UpdatePaymentStatusInput, void, UpdatePaymentStatusErrorCode>
implements UseCase<UpdatePaymentStatusInput, UpdatePaymentStatusResult, UpdatePaymentStatusErrorCode>
{
constructor(
private readonly paymentRepository: IPaymentRepository,
private readonly output: UseCaseOutputPort<UpdatePaymentStatusResult>,
) {}
async execute(input: UpdatePaymentStatusInput): Promise<Result<void, ApplicationErrorCode<UpdatePaymentStatusErrorCode>>> {
async execute(input: UpdatePaymentStatusInput): Promise<Result<UpdatePaymentStatusResult, ApplicationErrorCode<UpdatePaymentStatusErrorCode>>> {
const { paymentId, status } = input;
const existingPayment = await this.paymentRepository.findById(paymentId);
@@ -47,8 +45,6 @@ export class UpdatePaymentStatusUseCase
const savedPayment = await this.paymentRepository.update(updatedPayment as Payment);
this.output.present({ payment: savedPayment });
return Result.ok(undefined);
return Result.ok({ payment: savedPayment });
}
}