34 lines
932 B
Go
34 lines
932 B
Go
package model
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"hepa-calc-api/global"
|
|
"time"
|
|
)
|
|
|
|
// SystemSingle 配置-单项配置
|
|
type SystemSingle struct {
|
|
SystemSingleId int64 `gorm:"column:system_single_id;type:bigint(19);primary_key;comment:主键id" json:"system_single_id"`
|
|
FirstTimePrice *float64 `gorm:"column:first_time_price;type:decimal(10,2);comment:首次购买价格" json:"first_time_price"`
|
|
ValidDays int `gorm:"column:valid_days;type:int(5);default:1;comment:购买后有效天数" json:"valid_days"`
|
|
Model
|
|
}
|
|
|
|
func (m *SystemSingle) TableName() string {
|
|
return "system_single"
|
|
}
|
|
|
|
func (m *SystemSingle) BeforeCreate(tx *gorm.DB) error {
|
|
if m.SystemSingleId == 0 {
|
|
m.SystemSingleId = 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
|
|
}
|