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';
|
||||
|
||||
@@ -29,18 +29,15 @@ export type UpdateLeagueSeasonScheduleRaceErrorCode =
|
||||
| 'REPOSITORY_ERROR';
|
||||
|
||||
export class UpdateLeagueSeasonScheduleRaceUseCase {
|
||||
constructor(
|
||||
private readonly seasonRepository: ISeasonRepository,
|
||||
constructor(private readonly seasonRepository: ISeasonRepository,
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<UpdateLeagueSeasonScheduleRaceResult>,
|
||||
) {}
|
||||
private readonly logger: Logger) {}
|
||||
|
||||
async execute(
|
||||
input: UpdateLeagueSeasonScheduleRaceInput,
|
||||
): Promise<
|
||||
Result<
|
||||
void,
|
||||
UpdateLeagueSeasonScheduleRaceResult,
|
||||
ApplicationErrorCode<UpdateLeagueSeasonScheduleRaceErrorCode, { message: string }>
|
||||
>
|
||||
> {
|
||||
@@ -102,9 +99,7 @@ export class UpdateLeagueSeasonScheduleRaceUseCase {
|
||||
await this.raceRepository.update(updated);
|
||||
|
||||
const result: UpdateLeagueSeasonScheduleRaceResult = { success: 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 update league season schedule race', error, {
|
||||
|
||||
Reference in New Issue
Block a user