|
| 1 | +package com.example.workaround.model; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | + |
| 5 | +import java.util.Date; |
| 6 | + |
| 7 | +import javax.persistence.Column; |
| 8 | +import javax.persistence.Entity; |
| 9 | +import javax.persistence.EntityListeners; |
| 10 | +import javax.persistence.GeneratedValue; |
| 11 | +import javax.persistence.GenerationType; |
| 12 | +import javax.persistence.Id; |
| 13 | +import javax.persistence.Table; |
| 14 | +import javax.persistence.Temporal; |
| 15 | +import javax.persistence.TemporalType; |
| 16 | +import javax.validation.constraints.NotBlank; |
| 17 | + |
| 18 | +import org.springframework.data.annotation.CreatedDate; |
| 19 | +import org.springframework.data.annotation.LastModifiedDate; |
| 20 | +import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
| 21 | + |
| 22 | +@Entity |
| 23 | +@Table(name = "notes") |
| 24 | +@EntityListeners(AuditingEntityListener.class) |
| 25 | +@JsonIgnoreProperties(value = { "createdAt", "updatedAt" }, allowGetters = true) |
| 26 | +public class Note { |
| 27 | + @Id |
| 28 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 29 | + private Long id; |
| 30 | + |
| 31 | + @NotBlank |
| 32 | + private String title; |
| 33 | + |
| 34 | + @NotBlank |
| 35 | + private String content; |
| 36 | + |
| 37 | + @Column(nullable = false, updatable = false) |
| 38 | + @Temporal(TemporalType.TIMESTAMP) |
| 39 | + @CreatedDate |
| 40 | + private Date createdAt; |
| 41 | + |
| 42 | + @Column(nullable = false) |
| 43 | + @Temporal(TemporalType.TIMESTAMP) |
| 44 | + @LastModifiedDate |
| 45 | + private Date updatedAt; |
| 46 | + |
| 47 | + public Long getId() { |
| 48 | + return id; |
| 49 | + } |
| 50 | + |
| 51 | + public void setId(Long id) { |
| 52 | + this.id = id; |
| 53 | + } |
| 54 | + |
| 55 | + public String getTitle() { |
| 56 | + return title; |
| 57 | + } |
| 58 | + |
| 59 | + public void setTitle(String title) { |
| 60 | + this.title = title; |
| 61 | + } |
| 62 | + |
| 63 | + public String getContent() { |
| 64 | + return content; |
| 65 | + } |
| 66 | + |
| 67 | + public void setContent(String content) { |
| 68 | + this.content = content; |
| 69 | + } |
| 70 | + |
| 71 | + public Date getCreatedAt() { |
| 72 | + return createdAt; |
| 73 | + } |
| 74 | + |
| 75 | + public void setCreatedAt(Date createdAt) { |
| 76 | + this.createdAt = createdAt; |
| 77 | + } |
| 78 | + |
| 79 | + public Date getUpdatedAt() { |
| 80 | + return updatedAt; |
| 81 | + } |
| 82 | + |
| 83 | + public void setUpdatedAt(Date updatedAt) { |
| 84 | + this.updatedAt = updatedAt; |
| 85 | + } |
| 86 | + |
| 87 | +} |
0 commit comments