42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ConfigType 配置类型
|
|
type ConfigType string
|
|
|
|
const (
|
|
ConfigTypeString ConfigType = "STRING"
|
|
ConfigTypeInteger ConfigType = "INTEGER"
|
|
ConfigTypeBoolean ConfigType = "BOOLEAN"
|
|
ConfigTypeJSON ConfigType = "JSON"
|
|
)
|
|
|
|
// SystemConfig 系统配置模型
|
|
type SystemConfig struct {
|
|
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
Key string `gorm:"column:key;type:varchar(100);not null;uniqueIndex" json:"key"`
|
|
Value string `gorm:"column:value;type:text;not null" json:"value"`
|
|
Description string `gorm:"column:description;type:varchar(255);not null;default:''" json:"description"`
|
|
Type ConfigType `gorm:"column:type;type:varchar(50);not null;default:'STRING'" json:"type"` // STRING, INTEGER, BOOLEAN, JSON
|
|
IsPublic bool `gorm:"column:is_public;not null;default:false;index" json:"is_public"` // 是否可被前端获取
|
|
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (SystemConfig) TableName() string {
|
|
return "system_config"
|
|
}
|
|
|
|
// SystemConfigPublicResponse 公开配置响应
|
|
type SystemConfigPublicResponse struct {
|
|
SiteName string `json:"site_name"`
|
|
SiteDescription string `json:"site_description"`
|
|
RegistrationEnabled bool `json:"registration_enabled"`
|
|
MaintenanceMode bool `json:"maintenance_mode"`
|
|
Announcement string `json:"announcement"`
|
|
}
|