-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathEmailSendHistory.java
More file actions
92 lines (78 loc) · 2.64 KB
/
EmailSendHistory.java
File metadata and controls
92 lines (78 loc) · 2.64 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package ceos.backend.infra.ses.domain;
import ceos.backend.global.common.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "email_send_history")
public class EmailSendHistory extends BaseEntity {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "recipient_email")
private String recipientEmail;
@Column(name = "subject")
private String subject;
@Column(name = "template_name")
private String templateName;
@Enumerated(EnumType.STRING)
@Column(name = "email_type")
private EmailType emailType;
@Enumerated(EnumType.STRING)
@Column(name = "send_status")
private SendStatus sendStatus;
@Column(name = "message_id", length = 255)
private String messageId;
@Column(name = "error_message", length = 1000)
private String errorMessage;
@Builder(access = AccessLevel.PRIVATE)
private EmailSendHistory(
String recipientEmail,
String subject,
String templateName,
EmailType emailType,
SendStatus sendStatus,
String messageId,
String errorMessage) {
this.recipientEmail = recipientEmail;
this.subject = subject;
this.templateName = templateName;
this.emailType = emailType;
this.sendStatus = sendStatus;
this.messageId = messageId;
this.errorMessage = errorMessage;
}
public static EmailSendHistory createSuccess(
String recipientEmail,
String subject,
String templateName,
EmailType emailType,
String messageId) {
return EmailSendHistory.builder()
.recipientEmail(recipientEmail)
.subject(subject)
.templateName(templateName)
.emailType(emailType)
.sendStatus(SendStatus.SUCCESS)
.messageId(messageId)
.build();
}
public static EmailSendHistory createFailure(
String recipientEmail,
String subject,
String templateName,
EmailType emailType,
String errorMessage) {
return EmailSendHistory.builder()
.recipientEmail(recipientEmail)
.subject(subject)
.templateName(templateName)
.emailType(emailType)
.sendStatus(SendStatus.FAILURE)
.errorMessage(errorMessage)
.build();
}
}