refactor use cases
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
@@ -23,14 +23,13 @@ export class PublishLeagueSeasonScheduleUseCase {
|
||||
constructor(
|
||||
private readonly seasonRepository: ISeasonRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<PublishLeagueSeasonScheduleResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: PublishLeagueSeasonScheduleInput,
|
||||
): Promise<
|
||||
Result<
|
||||
void,
|
||||
PublishLeagueSeasonScheduleResult,
|
||||
ApplicationErrorCode<PublishLeagueSeasonScheduleErrorCode, { message: string }>
|
||||
>
|
||||
> {
|
||||
@@ -48,16 +47,15 @@ export class PublishLeagueSeasonScheduleUseCase {
|
||||
});
|
||||
}
|
||||
|
||||
await this.seasonRepository.update(season.withSchedulePublished(true));
|
||||
const updatedSeason = season.withSchedulePublished(true);
|
||||
await this.seasonRepository.update(updatedSeason);
|
||||
|
||||
const result: PublishLeagueSeasonScheduleResult = {
|
||||
success: true,
|
||||
seasonId: season.id,
|
||||
published: true,
|
||||
};
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (err) {
|
||||
const error = err instanceof Error ? err : new Error('Unknown error');
|
||||
this.logger.error('Failed to publish league season schedule', error, {
|
||||
|
||||
Reference in New Issue
Block a user