This commit is contained in:
2025-12-10 18:28:32 +01:00
parent 6d61be9c51
commit 1303a14493
108 changed files with 3366 additions and 1559 deletions

View File

@@ -1,6 +1,6 @@
/**
* Application Query: GetSponsorSponsorshipsQuery
*
* Application Use Case: GetSponsorSponsorshipsUseCase
*
* Returns detailed sponsorship information for a sponsor's campaigns/sponsorships page.
*/
@@ -11,6 +11,7 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
import type { SponsorshipTier, SponsorshipStatus } from '../../domain/entities/SeasonSponsorship';
import type { ISponsorSponsorshipsPresenter } from '../presenters/ISponsorSponsorshipsPresenter';
export interface GetSponsorSponsorshipsQueryParams {
sponsorId: string;
@@ -22,6 +23,8 @@ export interface SponsorshipDetailDTO {
leagueName: string;
seasonId: string;
seasonName: string;
seasonStartDate?: Date;
seasonEndDate?: Date;
tier: SponsorshipTier;
status: SponsorshipStatus;
pricing: {
@@ -59,7 +62,7 @@ export interface SponsorSponsorshipsDTO {
};
}
export class GetSponsorSponsorshipsQuery {
export class GetSponsorSponsorshipsUseCase {
constructor(
private readonly sponsorRepository: ISponsorRepository,
private readonly seasonSponsorshipRepository: ISeasonSponsorshipRepository,
@@ -67,14 +70,16 @@ export class GetSponsorSponsorshipsQuery {
private readonly leagueRepository: ILeagueRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly raceRepository: IRaceRepository,
private readonly presenter: ISponsorSponsorshipsPresenter,
) {}
async execute(params: GetSponsorSponsorshipsQueryParams): Promise<SponsorSponsorshipsDTO | null> {
async execute(params: GetSponsorSponsorshipsQueryParams): Promise<void> {
const { sponsorId } = params;
const sponsor = await this.sponsorRepository.findById(sponsorId);
if (!sponsor) {
return null;
this.presenter.present(null);
return;
}
// Get all sponsorships for this sponsor
@@ -116,6 +121,8 @@ export class GetSponsorSponsorshipsQuery {
leagueName: league.name,
seasonId: season.id,
seasonName: season.name,
seasonStartDate: season.startDate,
seasonEndDate: season.endDate,
tier: sponsorship.tier,
status: sponsorship.status,
pricing: {
@@ -143,7 +150,7 @@ export class GetSponsorSponsorshipsQuery {
const activeSponsorships = sponsorships.filter(s => s.status === 'active').length;
return {
this.presenter.present({
sponsorId,
sponsorName: sponsor.name,
sponsorships: sponsorshipDetails,
@@ -154,6 +161,6 @@ export class GetSponsorSponsorshipsQuery {
totalPlatformFees,
currency: 'USD',
},
};
});
}
}