42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
)
|
|
|
|
// SmsMessage 是节点短信发送队列记录。
|
|
// 业务事务内只写入 pending,真正的发送由后台任务完成,
|
|
// 因此短信通道异常不会影响业务提交。
|
|
type SmsMessage struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
UserID uint64 `gorm:"not null;default:0" json:"user_id"`
|
|
Phone string `gorm:"size:32;not null;default:''" json:"phone"`
|
|
Node string `gorm:"size:64;not null" json:"node"`
|
|
BizType string `gorm:"size:32;not null;default:''" json:"biz_type"`
|
|
BizID uint64 `gorm:"not null;default:0" json:"biz_id"`
|
|
DistributionSiteID *uint64 `gorm:"index" json:"distribution_site_id,omitempty"`
|
|
TemplateCode string `gorm:"size:64;not null;default:''" json:"template_code"`
|
|
TemplateParams datatypes.JSON `json:"template_params"`
|
|
SignName string `gorm:"size:64;not null;default:''" json:"sign_name"`
|
|
Status string `gorm:"size:16;not null;default:'pending'" json:"status"`
|
|
SkipReason string `gorm:"size:128;not null;default:''" json:"skip_reason"`
|
|
RetryCount int `gorm:"not null;default:0" json:"retry_count"`
|
|
LastError string `gorm:"size:512;not null;default:''" json:"last_error"`
|
|
SentAt *time.Time `json:"sent_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (SmsMessage) TableName() string {
|
|
return "sms_messages"
|
|
}
|
|
|
|
const (
|
|
SmsStatusPending = "pending"
|
|
SmsStatusSent = "sent"
|
|
SmsStatusFailed = "failed"
|
|
SmsStatusSkipped = "skipped"
|
|
)
|