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