-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubscription.java
More file actions
60 lines (50 loc) · 1.28 KB
/
Subscription.java
File metadata and controls
60 lines (50 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.openpodcastapi.opa.subscription.model;
import jakarta.persistence.*;
import lombok.*;
import java.time.Instant;
import java.util.Set;
import java.util.UUID;
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "subscriptions")
public class Subscription {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Generated
@Getter
private Long id;
@Getter
@Setter
@Column(unique = true, nullable = false, updatable = false, columnDefinition = "uuid")
private UUID uuid;
@Getter
@Setter
@Column(nullable = false)
private String feedUrl;
@Getter
@Setter
@OneToMany(mappedBy = "subscription")
private Set<UserSubscription> subscribers;
@Getter
@Setter
@Column(updatable = false, nullable = false)
private Instant createdAt;
@Getter
@Setter
@Column(nullable = false)
private Instant updatedAt;
@PrePersist
public void prePersist() {
final Instant timestamp = Instant.now();
// Store the created date and set an updated timestamp
this.setCreatedAt(timestamp);
this.setUpdatedAt(timestamp);
}
@PreUpdate
public void preUpdate() {
// Store the timestamp of the update
this.setUpdatedAt(Instant.now());
}
}