mirror of
https://github.com/usatiuk/y.git
synced 2025-10-28 18:37:47 +01:00
posts prettier
This commit is contained in:
@@ -2,5 +2,5 @@ package com.usatiuk.tjv.y.server.dto;
|
||||
|
||||
import com.usatiuk.tjv.y.server.entity.Post;
|
||||
|
||||
public record PostTo(Long id, String authorUuid, String text) {
|
||||
public record PostTo(Long id, String authorUuid, String text, Long createdAt) {
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.usatiuk.tjv.y.server.dto.converters;
|
||||
|
||||
import com.usatiuk.tjv.y.server.dto.PersonTo;
|
||||
import com.usatiuk.tjv.y.server.dto.PostTo;
|
||||
import com.usatiuk.tjv.y.server.entity.Person;
|
||||
import com.usatiuk.tjv.y.server.entity.Post;
|
||||
|
||||
public class PostMapper {
|
||||
public static PostTo makeDto(Post post) {
|
||||
return new PostTo(post.getId(), post.getAuthor().getUuid(), post.getText());
|
||||
return new PostTo(post.getId(), post.getAuthor().getUuid(), post.getText(), post.getCreatedAt().getEpochSecond());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.usatiuk.tjv.y.server.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@@ -21,9 +28,12 @@ public class Post implements EntityWithId<Long> {
|
||||
@ManyToOne
|
||||
private Person author;
|
||||
|
||||
@Lob
|
||||
@NotBlank
|
||||
private String text;
|
||||
|
||||
@CreationTimestamp
|
||||
private Instant createdAt;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user