41 lines
1.9 KiB
Go
41 lines
1.9 KiB
Go
|
package entity
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
// DeliveryStatus 傳送狀態
|
||
|
type DeliveryStatus string
|
||
|
|
||
|
const (
|
||
|
DeliveryStatusPending DeliveryStatus = "pending" // 待發送
|
||
|
DeliveryStatusSending DeliveryStatus = "sending" // 發送中
|
||
|
DeliveryStatusSuccess DeliveryStatus = "success" // 發送成功
|
||
|
DeliveryStatusFailed DeliveryStatus = "failed" // 發送失敗
|
||
|
DeliveryStatusRetrying DeliveryStatus = "retrying" // 重試中
|
||
|
DeliveryStatusCancelled DeliveryStatus = "cancelled" // 已取消
|
||
|
)
|
||
|
|
||
|
// DeliveryHistory 傳送歷史記錄
|
||
|
type DeliveryHistory struct {
|
||
|
ID string `bson:"_id" json:"id"`
|
||
|
Type string `bson:"type" json:"type"` // email/sms
|
||
|
Recipient string `bson:"recipient" json:"recipient"` // 收件人
|
||
|
Subject string `bson:"subject" json:"subject"` // 主題
|
||
|
Content string `bson:"content" json:"content"` // 內容
|
||
|
Provider string `bson:"provider" json:"provider"` // aws_ses, mitake, smtp
|
||
|
Status DeliveryStatus `bson:"status" json:"status"` // 狀態
|
||
|
AttemptCount int `bson:"attempt_count" json:"attempt_count"` // 嘗試次數
|
||
|
ErrorMessage string `bson:"error_message" json:"error_message"` // 錯誤訊息
|
||
|
CreatedAt time.Time `bson:"created_at" json:"created_at"`
|
||
|
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"`
|
||
|
CompletedAt *time.Time `bson:"completed_at" json:"completed_at"` // 完成時間
|
||
|
}
|
||
|
|
||
|
// DeliveryAttempt 單次發送嘗試記錄
|
||
|
type DeliveryAttempt struct {
|
||
|
Provider string `bson:"provider" json:"provider"`
|
||
|
AttemptAt time.Time `bson:"attempt_at" json:"attempt_at"`
|
||
|
Success bool `bson:"success" json:"success"`
|
||
|
ErrorMessage string `bson:"error_message" json:"error_message"`
|
||
|
Duration int64 `bson:"duration_ms" json:"duration_ms"` // 執行時間(毫秒)
|
||
|
}
|