Browse Source

fix client-side types about comment as backend returns

pull/1433/head
ayanamizuta 3 years ago
parent
commit
7a3418841d
4 changed files with 10 additions and 13 deletions
  1. 14
      frontend/domain/models/comment/comment.ts
  2. 3
      frontend/domain/models/comment/commentRepository.ts
  3. 2
      frontend/services/application/comment/commentApplicationService.ts
  4. 4
      frontend/services/application/comment/commentData.ts

14
frontend/domain/models/comment/comment.ts

@ -41,18 +41,17 @@ export class CommentItem {
public id: number,
public user: number,
public username: string,
public document: number,
public documentText: string,
public example: number,
public text: string,
public createdAt: string
) {}
static valueOf(
{ id, user, username, document, document_text, text, created_at }:
{ id: number, user: number, username: string, document: number,
document_text: string, text: string, created_at: string }
{ id, user, username, example, text, created_at }:
{ id: number, user: number, username: string, example: number,
text: string, created_at: string }
): CommentItem {
return new CommentItem(id, user, username, document, document_text, text, created_at)
return new CommentItem(id, user, username, example, text, created_at)
}
by(userId: number) {
@ -64,8 +63,7 @@ export class CommentItem {
id: this.id,
user: this.user,
username: this.username,
document: this.document,
document_text: this.documentText,
document: this.example,
text: this.text,
created_at: this.createdAt
}

3
frontend/domain/models/comment/commentRepository.ts

@ -4,8 +4,7 @@ export interface CommentItemResponse {
id: number,
user: number,
username: string,
document: number,
document_text: string,
example: number,
text: string,
created_at: string
}

2
frontend/services/application/comment/commentApplicationService.ts

@ -23,7 +23,7 @@ export class CommentApplicationService {
public update(projectId: string, docId: number, item: CommentReadDTO): Promise<CommentItem> {
const comment = new CommentItem(
item.id, item.user, item.username, docId, item.documentText, item.text, item.createdAt
item.id, item.user, item.username, docId, item.text, item.createdAt
)
return this.repository.update(projectId, docId, comment)
}

4
frontend/services/application/comment/commentData.ts

@ -5,7 +5,7 @@ export class CommentReadDTO {
id: number;
user: number;
username: string;
documentText: string;
example: number;
text: string;
createdAt: string;
@ -13,7 +13,7 @@ export class CommentReadDTO {
this.id = item.id;
this.user = item.user;
this.username = item.username;
this.documentText = item.documentText;
this.example = item.example;
this.text = item.text;
this.createdAt = item.createdAt;
}

Loading…
Cancel
Save