refactor api modules
This commit is contained in:
@@ -24,7 +24,7 @@ import { SponsorProfileDTO } from './dtos/SponsorProfileDTO';
|
||||
import { NotificationSettingsDTO } from './dtos/NotificationSettingsDTO';
|
||||
import { PrivacySettingsDTO } from './dtos/PrivacySettingsDTO';
|
||||
import type { AcceptSponsorshipRequestResultViewModel } from './presenters/AcceptSponsorshipRequestPresenter';
|
||||
import type { RejectSponsorshipRequestResultDTO } from '@core/racing/application/use-cases/RejectSponsorshipRequestUseCase';
|
||||
import type { RejectSponsorshipRequestResult } from '@core/racing/application/use-cases/RejectSponsorshipRequestUseCase';
|
||||
|
||||
@ApiTags('sponsors')
|
||||
@Controller('sponsors')
|
||||
@@ -39,8 +39,7 @@ export class SponsorController {
|
||||
type: GetEntitySponsorshipPricingResultDTO,
|
||||
})
|
||||
async getEntitySponsorshipPricing(): Promise<GetEntitySponsorshipPricingResultDTO> {
|
||||
const presenter = await this.sponsorService.getEntitySponsorshipPricing();
|
||||
return presenter.viewModel;
|
||||
return await this.sponsorService.getEntitySponsorshipPricing();
|
||||
}
|
||||
|
||||
@Get()
|
||||
@@ -51,8 +50,7 @@ export class SponsorController {
|
||||
type: GetSponsorsOutputDTO,
|
||||
})
|
||||
async getSponsors(): Promise<GetSponsorsOutputDTO> {
|
||||
const presenter = await this.sponsorService.getSponsors();
|
||||
return presenter.viewModel;
|
||||
return await this.sponsorService.getSponsors();
|
||||
}
|
||||
|
||||
@Post()
|
||||
@@ -64,8 +62,7 @@ export class SponsorController {
|
||||
type: CreateSponsorOutputDTO,
|
||||
})
|
||||
async createSponsor(@Body() input: CreateSponsorInputDTO): Promise<CreateSponsorOutputDTO> {
|
||||
const presenter = await this.sponsorService.createSponsor(input);
|
||||
return presenter.viewModel;
|
||||
return await this.sponsorService.createSponsor(input);
|
||||
}
|
||||
|
||||
@Get('dashboard/:sponsorId')
|
||||
@@ -78,11 +75,10 @@ export class SponsorController {
|
||||
@ApiResponse({ status: 404, description: 'Sponsor not found' })
|
||||
async getSponsorDashboard(
|
||||
@Param('sponsorId') sponsorId: string,
|
||||
): Promise<SponsorDashboardDTO | null> {
|
||||
const presenter = await this.sponsorService.getSponsorDashboard({
|
||||
): Promise<SponsorDashboardDTO> {
|
||||
return await this.sponsorService.getSponsorDashboard({
|
||||
sponsorId,
|
||||
} as GetSponsorDashboardQueryParamsDTO);
|
||||
return presenter.viewModel;
|
||||
}
|
||||
|
||||
@Get(':sponsorId/sponsorships')
|
||||
@@ -97,11 +93,10 @@ export class SponsorController {
|
||||
@ApiResponse({ status: 404, description: 'Sponsor not found' })
|
||||
async getSponsorSponsorships(
|
||||
@Param('sponsorId') sponsorId: string,
|
||||
): Promise<SponsorSponsorshipsDTO | null> {
|
||||
const presenter = await this.sponsorService.getSponsorSponsorships({
|
||||
): Promise<SponsorSponsorshipsDTO> {
|
||||
return await this.sponsorService.getSponsorSponsorships({
|
||||
sponsorId,
|
||||
} as GetSponsorSponsorshipsQueryParamsDTO);
|
||||
return presenter.viewModel;
|
||||
}
|
||||
|
||||
@Get(':sponsorId')
|
||||
@@ -112,9 +107,8 @@ export class SponsorController {
|
||||
type: GetSponsorOutputDTO,
|
||||
})
|
||||
@ApiResponse({ status: 404, description: 'Sponsor not found' })
|
||||
async getSponsor(@Param('sponsorId') sponsorId: string): Promise<GetSponsorOutputDTO | null> {
|
||||
const presenter = await this.sponsorService.getSponsor(sponsorId);
|
||||
return presenter.viewModel;
|
||||
async getSponsor(@Param('sponsorId') sponsorId: string): Promise<GetSponsorOutputDTO> {
|
||||
return await this.sponsorService.getSponsor(sponsorId);
|
||||
}
|
||||
|
||||
@Get('requests')
|
||||
@@ -126,14 +120,13 @@ export class SponsorController {
|
||||
})
|
||||
async getPendingSponsorshipRequests(
|
||||
@Query() query: { entityType: string; entityId: string },
|
||||
): Promise<GetPendingSponsorshipRequestsOutputDTO | null> {
|
||||
const presenter = await this.sponsorService.getPendingSponsorshipRequests(
|
||||
): Promise<GetPendingSponsorshipRequestsOutputDTO> {
|
||||
return await this.sponsorService.getPendingSponsorshipRequests(
|
||||
query as {
|
||||
entityType: import('@core/racing/domain/entities/SponsorshipRequest').SponsorableEntityType;
|
||||
entityId: string;
|
||||
},
|
||||
);
|
||||
return presenter.viewModel;
|
||||
}
|
||||
|
||||
@Post('requests/:requestId/accept')
|
||||
@@ -146,11 +139,10 @@ export class SponsorController {
|
||||
@Param('requestId') requestId: string,
|
||||
@Body() input: AcceptSponsorshipRequestInputDTO,
|
||||
): Promise<AcceptSponsorshipRequestResultViewModel | null> {
|
||||
const presenter = await this.sponsorService.acceptSponsorshipRequest(
|
||||
return await this.sponsorService.acceptSponsorshipRequest(
|
||||
requestId,
|
||||
input.respondedBy,
|
||||
);
|
||||
return presenter.viewModel;
|
||||
}
|
||||
|
||||
@Post('requests/:requestId/reject')
|
||||
@@ -162,13 +154,12 @@ export class SponsorController {
|
||||
async rejectSponsorshipRequest(
|
||||
@Param('requestId') requestId: string,
|
||||
@Body() input: RejectSponsorshipRequestInputDTO,
|
||||
): Promise<RejectSponsorshipRequestResultDTO | null> {
|
||||
const presenter = await this.sponsorService.rejectSponsorshipRequest(
|
||||
): Promise<RejectSponsorshipRequestResult | null> {
|
||||
return await this.sponsorService.rejectSponsorshipRequest(
|
||||
requestId,
|
||||
input.respondedBy,
|
||||
input.reason,
|
||||
);
|
||||
return presenter.viewModel;
|
||||
}
|
||||
|
||||
@Get('billing/:sponsorId')
|
||||
@@ -181,8 +172,7 @@ export class SponsorController {
|
||||
invoices: InvoiceDTO[];
|
||||
stats: BillingStatsDTO;
|
||||
}> {
|
||||
const presenter = await this.sponsorService.getSponsorBilling(sponsorId);
|
||||
return presenter.viewModel;
|
||||
return await this.sponsorService.getSponsorBilling(sponsorId);
|
||||
}
|
||||
|
||||
@Get('leagues/available')
|
||||
|
||||
Reference in New Issue
Block a user