33 lines
799 B
Go
33 lines
799 B
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"time"
|
||
"vote-video-api/global"
|
||
)
|
||
|
||
// SystemConfig 配置-系统配置
|
||
type SystemConfig struct {
|
||
ConfigId int64 `gorm:"column:config_id;type:bigint(19);primary_key;comment:主键id" json:"config_id"`
|
||
IsDisplayRank int `gorm:"column:is_display_rank;type:tinyint(1);default:1;comment:是否展示排名(0:否 1:是)" json:"is_display_rank"`
|
||
Model
|
||
}
|
||
|
||
func (m *SystemConfig) TableName() string {
|
||
return "system_config"
|
||
}
|
||
|
||
func (m *SystemConfig) BeforeCreate(tx *gorm.DB) error {
|
||
if m.ConfigId == 0 {
|
||
m.ConfigId = 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
|
||
}
|