autodoload
This commit is contained in:
parent
8cd565c647
commit
62afad71d3
6 changed files with 144 additions and 88 deletions
|
@ -6,15 +6,31 @@ export class Post {
|
|||
public readonly content: string
|
||||
public readonly media: string[]
|
||||
public readonly createdAt: Temporal.PlainDateTime
|
||||
public readonly authorName: string
|
||||
|
||||
constructor(postId: string, content: string, media: string[], createdAt: Temporal.PlainDateTime) {
|
||||
constructor(
|
||||
postId: string,
|
||||
content: string,
|
||||
media: string[],
|
||||
createdAt: Temporal.PlainDateTime,
|
||||
authorName: string,
|
||||
) {
|
||||
this.postId = postId
|
||||
this.content = content
|
||||
this.media = media
|
||||
this.createdAt = createdAt
|
||||
this.authorName = authorName
|
||||
}
|
||||
|
||||
public static fromDto(dto: components['schemas']['AuthorPostDto']): Post {
|
||||
return new Post(dto.postId, dto.content, dto.media, Temporal.PlainDateTime.from(dto.createdAt))
|
||||
public static fromDto(
|
||||
dto: components['schemas']['AuthorPostDto'] | components['schemas']['PublicPostDto'],
|
||||
): Post {
|
||||
return new Post(
|
||||
dto.postId,
|
||||
dto.content,
|
||||
dto.media,
|
||||
Temporal.PlainDateTime.from(dto.createdAt),
|
||||
dto.author.username,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue