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 id: number,
public user: number, public user: number,
public username: string, public username: string,
public document: number,
public documentText: string,
public example: number,
public text: string, public text: string,
public createdAt: string public createdAt: string
) {} ) {}
static valueOf( 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 { ): 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) { by(userId: number) {
@ -64,8 +63,7 @@ export class CommentItem {
id: this.id, id: this.id,
user: this.user, user: this.user,
username: this.username, username: this.username,
document: this.document,
document_text: this.documentText,
document: this.example,
text: this.text, text: this.text,
created_at: this.createdAt created_at: this.createdAt
} }

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

@ -4,8 +4,7 @@ export interface CommentItemResponse {
id: number, id: number,
user: number, user: number,
username: string, username: string,
document: number,
document_text: string,
example: number,
text: string, text: string,
created_at: 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> { public update(projectId: string, docId: number, item: CommentReadDTO): Promise<CommentItem> {
const comment = new 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) return this.repository.update(projectId, docId, comment)
} }

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

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

Loading…
Cancel
Save