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';
|
||||
|
||||
@@ -20,17 +20,14 @@ export type UnpublishLeagueSeasonScheduleErrorCode =
|
||||
| 'REPOSITORY_ERROR';
|
||||
|
||||
export class UnpublishLeagueSeasonScheduleUseCase {
|
||||
constructor(
|
||||
private readonly seasonRepository: ISeasonRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<UnpublishLeagueSeasonScheduleResult>,
|
||||
) {}
|
||||
constructor(private readonly seasonRepository: ISeasonRepository,
|
||||
private readonly logger: Logger) {}
|
||||
|
||||
async execute(
|
||||
input: UnpublishLeagueSeasonScheduleInput,
|
||||
): Promise<
|
||||
Result<
|
||||
void,
|
||||
UnpublishLeagueSeasonScheduleResult,
|
||||
ApplicationErrorCode<UnpublishLeagueSeasonScheduleErrorCode, { message: string }>
|
||||
>
|
||||
> {
|
||||
@@ -55,9 +52,7 @@ export class UnpublishLeagueSeasonScheduleUseCase {
|
||||
seasonId: season.id,
|
||||
published: false,
|
||||
};
|
||||
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 unpublish league season schedule', error, {
|
||||
|
||||
Reference in New Issue
Block a user