41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-open-api/global"
|
||
"time"
|
||
)
|
||
|
||
// Popup 弹窗表
|
||
type Popup struct {
|
||
PopupId int64 `gorm:"column:popup_id;type:bigint(19);primary_key;comment:主键id" json:"popup_id"`
|
||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
||
AppType int `gorm:"column:app_type;type:tinyint(4);comment:应用程序类型(1:小程序 2:app);NOT NULL" json:"app_type"`
|
||
ClientType int `gorm:"column:client_type;type:tinyint(4);comment:客户端类型(1:患者端 2:医生端 3:药师端);NOT NULL" json:"client_type"`
|
||
Status int `gorm:"column:status;type:tinyint(4);default:0;comment:状态(0:未弹 1:已弹)" json:"status"`
|
||
PopupType int `gorm:"column:popup_type;type:tinyint(4);comment:弹窗类型(1:结算费用规则 2:新优惠卷弹窗);NOT NULL" json:"popup_type"`
|
||
PopupTitle string `gorm:"column:popup_title;type:varchar(255);comment:标题" json:"popup_title"`
|
||
PopupContent string `gorm:"column:popup_content;type:varchar(1000);comment:内容" json:"popup_content"`
|
||
PopupImg string `gorm:"column:popup_img;type:varchar(255);comment:封面图片" json:"popup_img"`
|
||
PopupLink string `gorm:"column:popup_link;type:varchar(255);comment:跳转地址" json:"popup_link"`
|
||
Model
|
||
}
|
||
|
||
func (m *Popup) TableName() string {
|
||
return "gdxz_popup"
|
||
}
|
||
|
||
func (m *Popup) BeforeCreate(tx *gorm.DB) error {
|
||
if m.PopupId == 0 {
|
||
m.PopupId = 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
|
||
}
|