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 { IMembershipFeeRepository, IMemberPaymentRepository } from '../../d
import type { MemberPayment } from '../../domain/entities/MemberPayment';
import { MemberPaymentStatus } from '../../domain/entities/MemberPayment';
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,15 +27,14 @@ export interface UpdateMemberPaymentResult {
export type UpdateMemberPaymentErrorCode = 'MEMBERSHIP_FEE_NOT_FOUND';
export class UpdateMemberPaymentUseCase
implements UseCase<UpdateMemberPaymentInput, void, UpdateMemberPaymentErrorCode>
implements UseCase<UpdateMemberPaymentInput, UpdateMemberPaymentResult, UpdateMemberPaymentErrorCode>
{
constructor(
private readonly membershipFeeRepository: IMembershipFeeRepository,
private readonly memberPaymentRepository: IMemberPaymentRepository,
private readonly output: UseCaseOutputPort<UpdateMemberPaymentResult>,
) {}
async execute(input: UpdateMemberPaymentInput): Promise<Result<void, ApplicationErrorCode<UpdateMemberPaymentErrorCode>>> {
async execute(input: UpdateMemberPaymentInput): Promise<Result<UpdateMemberPaymentResult, ApplicationErrorCode<UpdateMemberPaymentErrorCode>>> {
const { feeId, driverId, status, paidAt } = input;
const fee = await this.membershipFeeRepository.findById(feeId);
@@ -73,8 +71,6 @@ export class UpdateMemberPaymentUseCase
const updatedPayment = await this.memberPaymentRepository.update(payment);
this.output.present({ payment: updatedPayment });
return Result.ok(undefined);
return Result.ok({ payment: updatedPayment });
}
}