22
33import jakarta .persistence .Column ;
44import jakarta .persistence .Entity ;
5+ import jakarta .persistence .EntityListeners ;
56import jakarta .persistence .EnumType ;
67import jakarta .persistence .Enumerated ;
78import jakarta .persistence .GeneratedValue ;
89import jakarta .persistence .GenerationType ;
910import jakarta .persistence .Id ;
1011import jakarta .persistence .Table ;
12+ import java .time .LocalDateTime ;
13+ import org .springframework .data .annotation .CreatedDate ;
14+ import org .springframework .data .annotation .LastModifiedDate ;
15+ import org .springframework .data .jpa .domain .support .AuditingEntityListener ;
1116
1217@ Entity
1318@ Table (name = "bulletins" )
19+ @ EntityListeners (AuditingEntityListener .class )
1420public class Bulletin {
1521
1622 @ Id
@@ -30,6 +36,14 @@ public class Bulletin {
3036 @ Column (nullable = false )
3137 private String contact ;
3238
39+ @ CreatedDate
40+ @ Column (name = "created_at" , nullable = false , updatable = false )
41+ private LocalDateTime createdAt ;
42+
43+ @ LastModifiedDate
44+ @ Column (name = "updated_at" , nullable = false )
45+ private LocalDateTime updatedAt ;
46+
3347 public String getContact () {
3448 return contact ;
3549 }
@@ -69,4 +83,20 @@ public void setState(BulletinState state) {
6983 public void setTitle (String title ) {
7084 this .title = title ;
7185 }
86+
87+ public LocalDateTime getCreatedAt () {
88+ return createdAt ;
89+ }
90+
91+ public void setCreatedAt (LocalDateTime createdAt ) {
92+ this .createdAt = createdAt ;
93+ }
94+
95+ public LocalDateTime getUpdatedAt () {
96+ return updatedAt ;
97+ }
98+
99+ public void setUpdatedAt (LocalDateTime updatedAt ) {
100+ this .updatedAt = updatedAt ;
101+ }
72102}
0 commit comments