league service
This commit is contained in:
31
apps/api/src/modules/team/presenters/AllTeamsPresenter.ts
Normal file
31
apps/api/src/modules/team/presenters/AllTeamsPresenter.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { IAllTeamsPresenter, AllTeamsResultDTO, AllTeamsViewModel } from '@gridpilot/racing/application/presenters/IAllTeamsPresenter';
|
||||
import { TeamListItemViewModel } from '../dto/TeamDto';
|
||||
|
||||
export class AllTeamsPresenter implements IAllTeamsPresenter {
|
||||
private result: AllTeamsViewModel | null = null;
|
||||
|
||||
reset() {
|
||||
this.result = null;
|
||||
}
|
||||
|
||||
present(dto: AllTeamsResultDTO) {
|
||||
const teams: TeamListItemViewModel[] = dto.teams.map(team => ({
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
tag: team.tag,
|
||||
description: team.description,
|
||||
memberCount: team.memberCount,
|
||||
leagues: team.leagues || [],
|
||||
}));
|
||||
|
||||
this.result = {
|
||||
teams,
|
||||
totalCount: teams.length,
|
||||
};
|
||||
}
|
||||
|
||||
get viewModel(): AllTeamsViewModel {
|
||||
if (!this.result) throw new Error('Presenter not presented');
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user