NotificationPreference.java
1.25 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
package com.ecommerce.notification.model;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@Entity
@Table(name = "notification_preferences")
public class NotificationPreference {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "user_id", nullable = false)
private Long userId;
@Column(name = "channel", nullable = false)
private String channel; // ORDER, PAYMENT, SHIPPING, PROMOTION, SYSTEM
@Column(name = "email_enabled")
private Boolean emailEnabled = true;
@Column(name = "sms_enabled")
private Boolean smsEnabled = false;
@Column(name = "push_enabled")
private Boolean pushEnabled = true;
@Column(name = "in_app_enabled")
private Boolean inAppEnabled = true;
@Column(name = "created_at")
private LocalDateTime createdAt;
@Column(name = "updated_at")
private LocalDateTime updatedAt;
@PrePersist
protected void onCreate() {
createdAt = LocalDateTime.now();
updatedAt = LocalDateTime.now();
}
@PreUpdate
protected void onUpdate() {
updatedAt = LocalDateTime.now();
}
}