refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -6,7 +6,6 @@
import type { IPrizeRepository } from '../../domain/repositories/IPrizeRepository';
import type { UseCase } from '@core/shared/application/UseCase';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
@@ -21,14 +20,13 @@ export interface DeletePrizeResult {
export type DeletePrizeErrorCode = 'PRIZE_NOT_FOUND' | 'CANNOT_DELETE_AWARDED_PRIZE';
export class DeletePrizeUseCase
implements UseCase<DeletePrizeInput, void, DeletePrizeErrorCode>
implements UseCase<DeletePrizeInput, DeletePrizeResult, DeletePrizeErrorCode>
{
constructor(
private readonly prizeRepository: IPrizeRepository,
private readonly output: UseCaseOutputPort<DeletePrizeResult>,
) {}
async execute(input: DeletePrizeInput): Promise<Result<void, ApplicationErrorCode<DeletePrizeErrorCode>>> {
async execute(input: DeletePrizeInput): Promise<Result<DeletePrizeResult, ApplicationErrorCode<DeletePrizeErrorCode>>> {
const { prizeId } = input;
const prize = await this.prizeRepository.findById(prizeId);
@@ -42,8 +40,6 @@ export class DeletePrizeUseCase
await this.prizeRepository.delete(prizeId);
this.output.present({ success: true });
return Result.ok(undefined);
return Result.ok({ success: true });
}
}