refactor use cases
This commit is contained in:
@@ -5,7 +5,7 @@ import { LeagueScoringConfig } from '../../domain/entities/LeagueScoringConfig';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
|
||||
import type { ILeagueScoringConfigRepository } from '../../domain/repositories/ILeagueScoringConfigRepository';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { ChampionshipConfig } from '../../domain/types/ChampionshipConfig';
|
||||
import type { SessionType } from '../../domain/types/SessionType';
|
||||
import type { BonusRule } from '../../domain/types/BonusRule';
|
||||
@@ -60,12 +60,16 @@ export class CreateLeagueWithSeasonAndScoringUseCase {
|
||||
private readonly leagueScoringConfigRepository: ILeagueScoringConfigRepository,
|
||||
private readonly getLeagueScoringPresetById: (input: { presetId: string }) => Promise<ScoringPreset | undefined>,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<CreateLeagueWithSeasonAndScoringResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
command: CreateLeagueWithSeasonAndScoringCommand,
|
||||
): Promise<Result<void, ApplicationErrorCode<CreateLeagueWithSeasonAndScoringErrorCode>>> {
|
||||
): Promise<
|
||||
Result<
|
||||
CreateLeagueWithSeasonAndScoringResult,
|
||||
ApplicationErrorCode<CreateLeagueWithSeasonAndScoringErrorCode>
|
||||
>
|
||||
> {
|
||||
this.logger.debug('Executing CreateLeagueWithSeasonAndScoringUseCase', { command });
|
||||
const validation = this.validate(command);
|
||||
if (validation.isErr()) {
|
||||
@@ -135,8 +139,8 @@ export class CreateLeagueWithSeasonAndScoringUseCase {
|
||||
scoringConfig,
|
||||
};
|
||||
this.logger.debug('CreateLeagueWithSeasonAndScoringUseCase completed successfully.', { result });
|
||||
this.output.present(result);
|
||||
return Result.ok(undefined);
|
||||
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({
|
||||
code: 'REPOSITORY_ERROR',
|
||||
|
||||
Reference in New Issue
Block a user