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 { MembershipFee } from '../../domain/entities/MembershipFee';
import type { MemberPayment } 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';
@@ -25,15 +24,14 @@ export interface GetMembershipFeesResult {
}
export class GetMembershipFeesUseCase
implements UseCase<GetMembershipFeesInput, void, GetMembershipFeesErrorCode>
implements UseCase<GetMembershipFeesInput, GetMembershipFeesResult, GetMembershipFeesErrorCode>
{
constructor(
private readonly membershipFeeRepository: IMembershipFeeRepository,
private readonly memberPaymentRepository: IMemberPaymentRepository,
private readonly output: UseCaseOutputPort<GetMembershipFeesResult>,
) {}
async execute(input: GetMembershipFeesInput): Promise<Result<void, ApplicationErrorCode<GetMembershipFeesErrorCode>>> {
async execute(input: GetMembershipFeesInput): Promise<Result<GetMembershipFeesResult, ApplicationErrorCode<GetMembershipFeesErrorCode>>> {
const { leagueId, driverId } = input;
if (!leagueId) {
@@ -47,8 +45,6 @@ export class GetMembershipFeesUseCase
payments = await this.memberPaymentRepository.findByLeagueIdAndDriverId(leagueId, driverId, this.membershipFeeRepository);
}
this.output.present({ fee, payments });
return Result.ok(undefined);
return Result.ok({ fee, payments });
}
}