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

@@ -1,6 +1,5 @@
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
import { Result } from '@core/shared/application/Result';
import { UseCaseOutputPort } from '@core/shared/application';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { LeagueMembership } from '../../domain/entities/LeagueMembership';
@@ -21,14 +20,11 @@ export type RemoveLeagueMemberErrorCode =
| 'REPOSITORY_ERROR';
export class RemoveLeagueMemberUseCase {
constructor(
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly output: UseCaseOutputPort<RemoveLeagueMemberResult>,
) {}
constructor(private readonly leagueMembershipRepository: ILeagueMembershipRepository) {}
async execute(
params: RemoveLeagueMemberInput,
): Promise<Result<void, ApplicationErrorCode<RemoveLeagueMemberErrorCode, { message: string }>>> {
): Promise<Result<RemoveLeagueMemberResult, ApplicationErrorCode<RemoveLeagueMemberErrorCode, { message: string }>>> {
try {
const membership = await this.leagueMembershipRepository.getMembership(
params.leagueId,
@@ -65,13 +61,13 @@ export class RemoveLeagueMemberUseCase {
await this.leagueMembershipRepository.saveMembership(updatedMembership);
this.output.present({
const result: RemoveLeagueMemberResult = {
leagueId: params.leagueId,
memberId: params.targetDriverId,
removedRole: membership.role.toString(),
});
};
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const err = error as Error;