1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package no.eliashaugsbakk.clams.server.model;
import java.time.Instant;
public record Post(String title, String slug, String summary, Instant timePublished, Instant lastEdited, String content,
boolean isPublished) {
public Post(PostDTO postDTO, String slug) {
this(postDTO.title(), slug, postDTO.summary(), Instant.now(), Instant.now(), postDTO.content(),
postDTO.isPublished());
}
public static Post fromUpdated(Post existing, PostDTO postDTO) {
return new Post(postDTO.title(), existing.slug(), postDTO.summary(), existing.timePublished(), Instant.now(),
postDTO.content(), postDTO.isPublished());
}
}
|