36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package model
|
||
|
||
import (
|
||
"database/sql/driver"
|
||
"time"
|
||
)
|
||
|
||
// ConfigValue 存 system_config.config_value(JSON 列,可为 object 或 array)
|
||
type ConfigValue []byte
|
||
|
||
func (c ConfigValue) Value() (driver.Value, error) { return []byte(c), nil }
|
||
func (c *ConfigValue) Scan(value interface{}) error {
|
||
if value == nil {
|
||
*c = nil
|
||
return nil
|
||
}
|
||
b, ok := value.([]byte)
|
||
if !ok {
|
||
return nil
|
||
}
|
||
*c = append((*c)[0:0], b...)
|
||
return nil
|
||
}
|
||
|
||
// SystemConfig 对应表 system_config,JSON 输出与现网 1:1(小写驼峰)
|
||
type SystemConfig struct {
|
||
ID int `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||
ConfigKey string `gorm:"column:config_key;uniqueIndex;size:100" json:"configKey"`
|
||
ConfigValue ConfigValue `gorm:"column:config_value;type:json" json:"configValue"`
|
||
Description *string `gorm:"column:description;size:200" json:"description,omitempty"`
|
||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||
}
|
||
|
||
func (SystemConfig) TableName() string { return "system_config" }
|