39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-open-api/global"
|
||
"time"
|
||
)
|
||
|
||
// LogSms 日志-短信发送表
|
||
type LogSms struct {
|
||
LogId int64 `gorm:"column:log_id;type:bigint(19);primary_key;comment:主键id" json:"log_id"`
|
||
Type int `gorm:"column:type;type:tinyint(1);comment:类型(1:短信 2:邮件);NOT NULL" json:"type"`
|
||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:发送成功 2:发送失败)" json:"status"`
|
||
Phone string `gorm:"column:phone;type:varchar(20);comment:手机号" json:"phone"`
|
||
TemplateCode string `gorm:"column:template_code;type:varchar(20);comment:模版code" json:"template_code"`
|
||
ThirdCode string `gorm:"column:third_code;type:varchar(100);comment:第三方编码" json:"third_code"`
|
||
SceneDesc string `gorm:"column:scene_desc;type:varchar(255);comment:场景描述" json:"scene_desc"`
|
||
Remarks string `gorm:"column:remarks;type:varchar(255);comment:备注" json:"remarks"`
|
||
Model
|
||
}
|
||
|
||
func (m *LogSms) TableName() string {
|
||
return "gdxz_log_sms"
|
||
}
|
||
|
||
func (m *LogSms) BeforeCreate(tx *gorm.DB) error {
|
||
if m.LogId == 0 {
|
||
m.LogId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|