fix : unify dto conversion
This commit is contained in:
@@ -2,7 +2,9 @@ import { ConceptResponseDTO } from './conceptresponse.dto';
|
||||
|
||||
export class ConceptInTurnResponseDTO {
|
||||
constructor(partial: Partial<ConceptInTurnResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
this.order = partial.order;
|
||||
this.subconcept = partial.subconcept;
|
||||
this.markers = partial.markers;
|
||||
this.concept = new ConceptResponseDTO(partial.concept);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export class ConceptResponseDTO {
|
||||
constructor(partial: Partial<ConceptResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
this.id = partial.id;
|
||||
this.value = partial.value;
|
||||
}
|
||||
|
||||
id: number;
|
||||
|
||||
+18
-9
@@ -4,24 +4,33 @@ import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto';
|
||||
|
||||
export class GameResponseDTO {
|
||||
constructor(partial: Partial<GameResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
this.id = partial.id;
|
||||
this.started = partial.started;
|
||||
this.owner = new UserResponseDTO(partial.owner);
|
||||
this.players = partial.players.map((p) => new PlayerResponseDTO(p));
|
||||
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
|
||||
this.currentConcepts = partial.currentConcepts.map(
|
||||
(c) => new ConceptInTurnResponseDTO(c),
|
||||
);
|
||||
if (partial.players) {
|
||||
this.players = partial.players.map((p) => new PlayerResponseDTO(p));
|
||||
}
|
||||
|
||||
if (partial.currentConcepts) {
|
||||
this.currentConcepts = partial.currentConcepts.map(
|
||||
(c) => new ConceptInTurnResponseDTO(c),
|
||||
);
|
||||
}
|
||||
|
||||
if (partial.currentPlayer) {
|
||||
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
id: number;
|
||||
|
||||
owner: UserResponseDTO;
|
||||
|
||||
players: PlayerResponseDTO[];
|
||||
players: PlayerResponseDTO[] = [];
|
||||
|
||||
currentPlayer: PlayerResponseDTO;
|
||||
currentPlayer?: PlayerResponseDTO;
|
||||
|
||||
started: boolean;
|
||||
|
||||
currentConcepts: ConceptInTurnResponseDTO[];
|
||||
currentConcepts: ConceptInTurnResponseDTO[] = [];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UserResponseDTO } from './userresponse.dto';
|
||||
|
||||
export class PlayerResponseDTO {
|
||||
constructor(partial: Partial<PlayerResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
this.score = partial.score;
|
||||
this.user = new UserResponseDTO(partial.user);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export class UserResponseDTO {
|
||||
constructor(partial: Partial<UserResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
this.id = partial.id;
|
||||
this.username = partial.username;
|
||||
this.avatar = partial.avatar;
|
||||
}
|
||||
id: string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user