NotificationTemplate.java
1.46 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
package com.ecommerce.notification.model;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@Entity
@Table(name = "notification_templates")
public class NotificationTemplate {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name", unique = true, nullable = false)
private String name;
@Column(name = "type", nullable = false)
private String type; // EMAIL, SMS, PUSH
@Column(name = "channel", nullable = false)
private String channel; // ORDER, PAYMENT, SHIPPING, PROMOTION, SYSTEM
@Column(name = "subject")
private String subject;
@Column(name = "content", columnDefinition = "TEXT", nullable = false)
private String content;
@Column(name = "variables", columnDefinition = "TEXT")
private String variables; // JSON array of variable names
@Column(name = "is_active")
private Boolean isActive = true;
@Column(name = "description")
private String description;
@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();
}
}