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

@@ -3,8 +3,6 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
import type { SeasonStatus } from '../../domain/value-objects/SeasonStatus';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application';
export type SeasonLifecycleTransition =
| 'activate'
| 'complete'
@@ -39,15 +37,12 @@ export type ManageSeasonLifecycleErrorCode =
* ManageSeasonLifecycleUseCase
*/
export class ManageSeasonLifecycleUseCase {
constructor(
private readonly leagueRepository: ILeagueRepository,
private readonly seasonRepository: ISeasonRepository,
private readonly output: UseCaseOutputPort<ManageSeasonLifecycleResult>,
) {}
constructor(private readonly leagueRepository: ILeagueRepository,
private readonly seasonRepository: ISeasonRepository) {}
async execute(
input: ManageSeasonLifecycleInput,
): Promise<Result<void, ApplicationErrorCode<ManageSeasonLifecycleErrorCode, { message: string }>>> {
): Promise<Result<ManageSeasonLifecycleResult, ApplicationErrorCode<ManageSeasonLifecycleErrorCode, { message: string }>>> {
try {
const league = await this.leagueRepository.findById(input.leagueId);
if (!league) {
@@ -104,9 +99,7 @@ export class ManageSeasonLifecycleUseCase {
},
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',