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 { IMembershipFeeRepository } from '../../domain/repositories/IMembershipFeeRepository';
import type { MembershipFeeType, MembershipFee } from '../../domain/entities/MembershipFee';
import type { UseCase } from '@core/shared/application/UseCase';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { Result } from '@core/shared/application/Result';
export interface UpsertMembershipFeeInput {
@@ -24,14 +23,13 @@ export interface UpsertMembershipFeeResult {
export type UpsertMembershipFeeErrorCode = never;
export class UpsertMembershipFeeUseCase
implements UseCase<UpsertMembershipFeeInput, void, UpsertMembershipFeeErrorCode>
implements UseCase<UpsertMembershipFeeInput, UpsertMembershipFeeResult, UpsertMembershipFeeErrorCode>
{
constructor(
private readonly membershipFeeRepository: IMembershipFeeRepository,
private readonly output: UseCaseOutputPort<UpsertMembershipFeeResult>,
) {}
async execute(input: UpsertMembershipFeeInput): Promise<Result<void, never>> {
async execute(input: UpsertMembershipFeeInput): Promise<Result<UpsertMembershipFeeResult, never>> {
const { leagueId, seasonId, type, amount } = input;
let existingFee = await this.membershipFeeRepository.findByLeagueId(leagueId);
@@ -59,8 +57,6 @@ export class UpsertMembershipFeeUseCase
fee = await this.membershipFeeRepository.create(newFee);
}
this.output.present({ fee });
return Result.ok(undefined);
return Result.ok({ fee });
}
}