resolve manual DTOs

This commit is contained in:
2025-12-18 22:19:40 +01:00
parent 4a3087ae35
commit d617654928
179 changed files with 3716 additions and 1257 deletions

View File

@@ -0,0 +1,40 @@
/**
* Application Use Case: GetSponsorUseCase
*
* Retrieves a single sponsor by ID.
*/
import type { ISponsorRepository } from '../../domain/repositories/ISponsorRepository';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
export interface GetSponsorQueryParams {
sponsorId: string;
}
export class GetSponsorUseCase {
constructor(
private readonly sponsorRepository: ISponsorRepository,
) {}
async execute(params: GetSponsorQueryParams): Promise<Result<{ sponsor: { id: string; name: string; logoUrl?: string; websiteUrl?: string } } | null, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
try {
const sponsor = await this.sponsorRepository.findById(params.sponsorId);
if (!sponsor) {
return Result.ok(null);
}
const sponsorData = {
id: sponsor.id,
name: sponsor.name,
logoUrl: sponsor.logoUrl,
websiteUrl: sponsor.websiteUrl,
};
return Result.ok({ sponsor: sponsorData });
} catch {
return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch sponsor' });
}
}
}