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