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

@@ -7,7 +7,6 @@
import type { ISponsorshipPricingRepository } from '../../domain/repositories/ISponsorshipPricingRepository';
import type { Logger } from '@core/shared/application';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { SponsorableEntityType } from '../../domain/entities/SponsorshipRequest';
@@ -42,16 +41,13 @@ export type GetEntitySponsorshipPricingErrorCode =
| 'REPOSITORY_ERROR';
export class GetEntitySponsorshipPricingUseCase {
constructor(
private readonly sponsorshipPricingRepo: ISponsorshipPricingRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetEntitySponsorshipPricingResult>,
) {}
constructor(private readonly sponsorshipPricingRepo: ISponsorshipPricingRepository,
private readonly logger: Logger) {}
async execute(
input: GetEntitySponsorshipPricingInput,
): Promise<
Result<void, ApplicationErrorCode<GetEntitySponsorshipPricingErrorCode, { message: string }>>
Result<GetEntitySponsorshipPricingResult, ApplicationErrorCode<GetEntitySponsorshipPricingErrorCode, { message: string }>>
> {
this.logger.debug(
`Executing GetEntitySponsorshipPricingUseCase for entityType: ${input.entityType}, entityId: ${input.entityId}`,
@@ -107,9 +103,7 @@ export class GetEntitySponsorshipPricingUseCase {
this.logger.info(
`Successfully retrieved sponsorship pricing for entityType: ${input.entityType}, entityId: ${input.entityId}`,
);
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
this.logger.error(
'Error executing GetEntitySponsorshipPricingUseCase',