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

@@ -5,8 +5,6 @@ import type { ILeagueMembershipRepository } from '../../domain/repositories/ILea
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export type GetSeasonSponsorshipsInput = {
seasonId: string;
};
@@ -52,18 +50,15 @@ export type GetSeasonSponsorshipsErrorCode =
| 'REPOSITORY_ERROR';
export class GetSeasonSponsorshipsUseCase {
constructor(
private readonly seasonSponsorshipRepository: ISeasonSponsorshipRepository,
constructor(private readonly seasonSponsorshipRepository: ISeasonSponsorshipRepository,
private readonly seasonRepository: ISeasonRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly raceRepository: IRaceRepository,
private readonly output: UseCaseOutputPort<GetSeasonSponsorshipsResult>,
) {}
private readonly raceRepository: IRaceRepository) {}
async execute(
input: GetSeasonSponsorshipsInput,
): Promise<Result<void, ApplicationErrorCode<GetSeasonSponsorshipsErrorCode, { message: string }>>> {
): Promise<Result<GetSeasonSponsorshipsResult, ApplicationErrorCode<GetSeasonSponsorshipsErrorCode, { message: string }>>> {
try {
const { seasonId } = input;
@@ -137,12 +132,12 @@ export class GetSeasonSponsorshipsUseCase {
return detail;
});
this.output.present({
const result: GetSeasonSponsorshipsResult = {
seasonId,
sponsorships: sponsorshipDetails,
});
};
return Result.ok(undefined);
return Result.ok(result);
} catch (err) {
const error = err as { message?: string } | undefined;