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

@@ -7,7 +7,6 @@
import type { IPaymentRepository } from '../../domain/repositories/IPaymentRepository';
import type { Payment, PaymentType } 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 GetPaymentsResult {
export type GetPaymentsErrorCode = never;
export class GetPaymentsUseCase
implements UseCase<GetPaymentsInput, void, GetPaymentsErrorCode>
implements UseCase<GetPaymentsInput, GetPaymentsResult, GetPaymentsErrorCode>
{
constructor(
private readonly paymentRepository: IPaymentRepository,
private readonly output: UseCaseOutputPort<GetPaymentsResult>,
) {}
async execute(input: GetPaymentsInput): Promise<Result<void, ApplicationErrorCode<GetPaymentsErrorCode>>> {
async execute(input: GetPaymentsInput): Promise<Result<GetPaymentsResult, ApplicationErrorCode<GetPaymentsErrorCode>>> {
const { leagueId, payerId, type } = input;
const filters: { leagueId?: string; payerId?: string; type?: PaymentType } = {};
@@ -41,8 +39,6 @@ export class GetPaymentsUseCase
const payments = await this.paymentRepository.findByFilters(filters);
this.output.present({ payments });
return Result.ok(undefined);
return Result.ok({ payments });
}
}