refactor dtos to ports
This commit is contained in:
@@ -6,10 +6,8 @@ import type { ISeasonRepository } from '../../domain/repositories/ISeasonReposit
|
||||
import type { ILeagueScoringConfigRepository } from '../../domain/repositories/ILeagueScoringConfigRepository';
|
||||
import type { AsyncUseCase } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type {
|
||||
LeagueScoringPresetProvider,
|
||||
LeagueScoringPresetDTO,
|
||||
} from '../ports/LeagueScoringPresetProvider';
|
||||
import type { GetLeagueScoringPresetByIdInputPort } from '../ports/input/GetLeagueScoringPresetByIdInputPort';
|
||||
import type { LeagueScoringPresetOutputPort } from '../ports/output/LeagueScoringPresetOutputPort';
|
||||
import {
|
||||
LeagueVisibility,
|
||||
MIN_RANKED_LEAGUE_DRIVERS,
|
||||
@@ -45,7 +43,7 @@ export class CreateLeagueWithSeasonAndScoringUseCase
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly seasonRepository: ISeasonRepository,
|
||||
private readonly leagueScoringConfigRepository: ILeagueScoringConfigRepository,
|
||||
private readonly presetProvider: LeagueScoringPresetProvider,
|
||||
private readonly getLeagueScoringPresetById: (input: GetLeagueScoringPresetByIdInputPort) => Promise<LeagueScoringPresetOutputPort | undefined>,
|
||||
private readonly logger: Logger,
|
||||
) {}
|
||||
|
||||
@@ -96,8 +94,8 @@ export class CreateLeagueWithSeasonAndScoringUseCase
|
||||
|
||||
const presetId = command.scoringPresetId ?? 'club-default';
|
||||
this.logger.debug(`Attempting to retrieve scoring preset: ${presetId}`);
|
||||
const preset: LeagueScoringPresetDTO | undefined =
|
||||
this.presetProvider.getPresetById(presetId);
|
||||
const preset: LeagueScoringPresetOutputPort | undefined =
|
||||
await this.getLeagueScoringPresetById({ presetId });
|
||||
|
||||
if (!preset) {
|
||||
this.logger.error(`Unknown scoring preset: ${presetId}`);
|
||||
@@ -105,8 +103,19 @@ export class CreateLeagueWithSeasonAndScoringUseCase
|
||||
}
|
||||
this.logger.info(`Scoring preset ${preset.name} (${preset.id}) retrieved.`);
|
||||
|
||||
|
||||
const finalConfig = this.presetProvider.createScoringConfigFromPreset(preset.id, seasonId);
|
||||
// Note: createScoringConfigFromPreset business logic should be moved to domain layer
|
||||
// For now, we'll create a basic config structure
|
||||
const finalConfig = {
|
||||
id: uuidv4(),
|
||||
seasonId,
|
||||
scoringPresetId: preset.id,
|
||||
championships: {
|
||||
driver: command.enableDriverChampionship,
|
||||
team: command.enableTeamChampionship,
|
||||
nations: command.enableNationsChampionship,
|
||||
trophy: command.enableTrophyChampionship,
|
||||
},
|
||||
};
|
||||
this.logger.debug(`Scoring configuration created from preset ${preset.id}.`);
|
||||
|
||||
await this.leagueScoringConfigRepository.save(finalConfig);
|
||||
|
||||
Reference in New Issue
Block a user