refactor use cases
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { League } from '../../domain/entities/League';
|
||||
import type { Race } from '../../domain/entities/Race';
|
||||
@@ -40,12 +39,11 @@ export class GetRaceDetailUseCase {
|
||||
private readonly raceRegistrationRepository: IRaceRegistrationRepository,
|
||||
private readonly resultRepository: IResultRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
private readonly output: UseCaseOutputPort<GetRaceDetailResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: GetRaceDetailInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetRaceDetailErrorCode, { message: string }>>> {
|
||||
): Promise<Result<GetRaceDetailResult, ApplicationErrorCode<GetRaceDetailErrorCode, { message: string }>>> {
|
||||
const { raceId, driverId } = input;
|
||||
|
||||
try {
|
||||
@@ -97,9 +95,7 @@ export class GetRaceDetailUseCase {
|
||||
canRegister,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
@@ -112,4 +108,4 @@ export class GetRaceDetailUseCase {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user