refactor(common): AnswerDTO
This commit is contained in:
		
							parent
							
								
									8bf927d1c9
								
							
						
					
					
						commit
						6c9c8d782d
					
				
					 2 changed files with 19 additions and 16 deletions
				
			
		|  | @ -1,14 +1,7 @@ | ||||||
| import { mapToUserDTO, UserDTO } from './user.js'; | import { mapToUserDTO } from './user.js'; | ||||||
| import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from './question.js'; | import { mapToQuestionDTO, mapToQuestionId } from './question.js'; | ||||||
| import { Answer } from '../entities/questions/answer.entity.js'; | import { Answer } from '../entities/questions/answer.entity.js'; | ||||||
| 
 | import { AnswerDTO, AnswerId } from 'dwengo-1-common/src/interfaces/answer'; | ||||||
| export interface AnswerDTO { |  | ||||||
|     author: UserDTO; |  | ||||||
|     toQuestion: QuestionDTO; |  | ||||||
|     sequenceNumber: number; |  | ||||||
|     timestamp: string; |  | ||||||
|     content: string; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Convert a Question entity to a DTO format. |  * Convert a Question entity to a DTO format. | ||||||
|  | @ -23,12 +16,6 @@ export function mapToAnswerDTO(answer: Answer): AnswerDTO { | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface AnswerId { |  | ||||||
|     author: string; |  | ||||||
|     toQuestion: QuestionId; |  | ||||||
|     sequenceNumber: number; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export function mapToAnswerId(answer: AnswerDTO): AnswerId { | export function mapToAnswerId(answer: AnswerDTO): AnswerId { | ||||||
|     return { |     return { | ||||||
|         author: answer.author.username, |         author: answer.author.username, | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								common/src/interfaces/answer.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								common/src/interfaces/answer.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | ||||||
|  | import { UserDTO } from 'dwengo-1-backend/src/interfaces/user.js' | ||||||
|  | import { QuestionDTO } from 'dwengo-1-backend/src/interfaces/question.js' | ||||||
|  | 
 | ||||||
|  | export interface AnswerDTO { | ||||||
|  |     author: UserDTO; | ||||||
|  |     toQuestion: QuestionDTO; | ||||||
|  |     sequenceNumber: number; | ||||||
|  |     timestamp: string; | ||||||
|  |     content: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface AnswerId { | ||||||
|  |     author: string; | ||||||
|  |     toQuestion: QuestionId; | ||||||
|  |     sequenceNumber: number; | ||||||
|  | } | ||||||
		Reference in a new issue