refactor use cases
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
import type { IPrizeRepository } from '../../domain/repositories/IPrizeRepository';
|
||||
import type { Prize } from '../../domain/entities/Prize';
|
||||
import type { UseCase } from '@core/shared/application/UseCase';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
|
||||
export interface GetPrizesInput {
|
||||
@@ -20,14 +19,13 @@ export interface GetPrizesResult {
|
||||
}
|
||||
|
||||
export class GetPrizesUseCase
|
||||
implements UseCase<GetPrizesInput, void, never>
|
||||
implements UseCase<GetPrizesInput, GetPrizesResult, never>
|
||||
{
|
||||
constructor(
|
||||
private readonly prizeRepository: IPrizeRepository,
|
||||
private readonly output: UseCaseOutputPort<GetPrizesResult>,
|
||||
) {}
|
||||
|
||||
async execute(input: GetPrizesInput): Promise<Result<void, never>> {
|
||||
async execute(input: GetPrizesInput): Promise<Result<GetPrizesResult, never>> {
|
||||
const { leagueId, seasonId } = input;
|
||||
|
||||
let prizes;
|
||||
@@ -39,8 +37,6 @@ export class GetPrizesUseCase
|
||||
|
||||
prizes.sort((a, b) => a.position - b.position);
|
||||
|
||||
this.output.present({ prizes });
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok({ prizes });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user