vote-video-api/api/model/SystemConfig.go

33 lines
799 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}