2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 05:31:44 +08:00

fix: 严格所有字段的默认值

This commit is contained in:
2025-03-29 14:38:22 +08:00
parent 334c4bc4c1
commit 3c1062a006
14 changed files with 62 additions and 62 deletions

View File

@@ -8,11 +8,11 @@ import (
type App struct {
ID uint `gorm:"primaryKey" json:"id"`
Slug string `gorm:"not null;unique" json:"slug"`
Channel string `gorm:"not null" json:"channel"`
Version string `gorm:"not null" json:"version"`
Show bool `gorm:"not null" json:"show"`
ShowOrder int `gorm:"not null" json:"show_order"`
Slug string `gorm:"not null;default:'';unique" json:"slug"`
Channel string `gorm:"not null;default:''" json:"channel"`
Version string `gorm:"not null;default:''" json:"version"`
Show bool `gorm:"not null;default:false" json:"show"`
ShowOrder int `gorm:"not null;default:0" json:"show_order"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -11,7 +11,7 @@ const (
type Cache struct {
Key CacheKey `gorm:"primaryKey" json:"key"`
Value string `gorm:"not null" json:"value"`
Value string `gorm:"not null;default:''" json:"value"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -10,16 +10,16 @@ import (
type Cert struct {
ID uint `gorm:"primaryKey" json:"id"`
AccountID uint `gorm:"not null" json:"account_id"` // 关联的 ACME 账户 ID
WebsiteID uint `gorm:"not null" json:"website_id"` // 关联的网站 ID
DNSID uint `gorm:"not null" json:"dns_id"` // 关联的 DNS ID
Type string `gorm:"not null" json:"type"` // 证书类型 (P256, P384, 2048, 3072, 4096)
Domains []string `gorm:"not null;serializer:json" json:"domains"`
AutoRenew bool `gorm:"not null" json:"auto_renew"` // 自动续签
CertURL string `gorm:"not null" json:"cert_url"` // 证书 URL (续签时使用)
Cert string `gorm:"not null" json:"cert"` // 证书内容
Key string `gorm:"not null" json:"key"` // 私钥内容
Script string `gorm:"not null" json:"script"` // 部署脚本
AccountID uint `gorm:"not null;default:0" json:"account_id"` // 关联的 ACME 账户 ID
WebsiteID uint `gorm:"not null;default:0" json:"website_id"` // 关联的网站 ID
DNSID uint `gorm:"not null;default:0" json:"dns_id"` // 关联的 DNS ID
Type string `gorm:"not null;default:''" json:"type"` // 证书类型 (P256, P384, 2048, 3072, 4096)
Domains []string `gorm:"not null;default:'[]';serializer:json" json:"domains"`
AutoRenew bool `gorm:"not null;default:false" json:"auto_renew"` // 自动续签
CertURL string `gorm:"not null;default:''" json:"cert_url"` // 证书 URL (续签时使用)
Cert string `gorm:"not null;default:''" json:"cert"` // 证书内容
Key string `gorm:"not null;default:''" json:"key"` // 私钥内容
Script string `gorm:"not null;default:''" json:"script"` // 部署脚本
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`

View File

@@ -8,12 +8,12 @@ import (
type CertAccount struct {
ID uint `gorm:"primaryKey" json:"id"`
Email string `gorm:"not null" json:"email"`
CA string `gorm:"not null" json:"ca"` // CA 提供商 (letsencrypt, zerossl, sslcom, google, buypass)
Kid string `gorm:"not null" json:"kid"`
HmacEncoded string `gorm:"not null" json:"hmac_encoded"`
PrivateKey string `gorm:"not null" json:"private_key"`
KeyType string `gorm:"not null" json:"key_type"` // 密钥类型 (P256, P384, 2048, 3072, 4096)
Email string `gorm:"not null;default:''" json:"email"`
CA string `gorm:"not null;default:'letsencrypt'" json:"ca"` // CA 提供商 (letsencrypt, zerossl, sslcom, google, buypass)
Kid string `gorm:"not null;default:''" json:"kid"`
HmacEncoded string `gorm:"not null;default:''" json:"hmac_encoded"`
PrivateKey string `gorm:"not null;default:''" json:"private_key"`
KeyType string `gorm:"not null;default:'P256'" json:"key_type"` // 密钥类型 (P256, P384, 2048, 3072, 4096)
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`

View File

@@ -9,8 +9,8 @@ import (
type CertDNS struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null" json:"name"` // 备注名称
Type string `gorm:"not null" json:"type"` // DNS 提供商 (tencent, aliyun, cloudflare)
Name string `gorm:"not null;default:''" json:"name"` // 备注名称
Type string `gorm:"not null;default:'aliyun'" json:"type"` // DNS 提供商 (tencent, aliyun, cloudflare)
Data acme.DNSParam `gorm:"not null;serializer:json" json:"dns_param"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`

View File

@@ -8,12 +8,12 @@ import (
type Cron struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null;unique" json:"name"`
Status bool `gorm:"not null" json:"status"`
Type string `gorm:"not null" json:"type"`
Time string `gorm:"not null" json:"time"`
Shell string `gorm:"not null" json:"shell"`
Log string `gorm:"not null" json:"log"`
Name string `gorm:"not null;default:'';unique" json:"name"`
Status bool `gorm:"not null;default:false" json:"status"`
Type string `gorm:"not null;default:''" json:"type"`
Time string `gorm:"not null;default:''" json:"time"`
Shell string `gorm:"not null;default:''" json:"shell"`
Log string `gorm:"not null;default:''" json:"log"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -19,14 +19,14 @@ const (
type DatabaseServer struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null;unique" json:"name"`
Type DatabaseType `gorm:"not null" json:"type"`
Host string `gorm:"not null" json:"host"`
Port uint `gorm:"not null" json:"port"`
Username string `gorm:"not null" json:"username"`
Password string `gorm:"not null" json:"password"`
Name string `gorm:"not null;default:'';unique" json:"name"`
Type DatabaseType `gorm:"not null;default:''" json:"type"`
Host string `gorm:"not null;default:''" json:"host"`
Port uint `gorm:"not null;default:0" json:"port"`
Username string `gorm:"not null;default:''" json:"username"`
Password string `gorm:"not null;default:''" json:"password"`
Status DatabaseServerStatus `gorm:"-:all" json:"status"`
Remark string `gorm:"not null" json:"remark"`
Remark string `gorm:"not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -19,13 +19,13 @@ const (
type DatabaseUser struct {
ID uint `gorm:"primaryKey" json:"id"`
ServerID uint `gorm:"not null" json:"server_id"`
Username string `gorm:"not null" json:"username"`
Password string `gorm:"not null" json:"password"`
Host string `gorm:"not null" json:"host"` // 仅 mysql
Status DatabaseUserStatus `gorm:"-:all" json:"status"` // 仅显示
Privileges []string `gorm:"-:all" json:"privileges"` // 仅显示
Remark string `gorm:"not null" json:"remark"`
ServerID uint `gorm:"not null;default:0" json:"server_id"`
Username string `gorm:"not null;default:''" json:"username"`
Password string `gorm:"not null;default:''" json:"password"`
Host string `gorm:"not null;default:''" json:"host"` // 仅 mysql
Status DatabaseUserStatus `gorm:"-:all" json:"status"` // 仅显示
Privileges []string `gorm:"-:all" json:"privileges"` // 仅显示
Remark string `gorm:"not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`

View File

@@ -9,7 +9,7 @@ import (
type Monitor struct {
ID uint `gorm:"primaryKey" json:"id"`
Info types.CurrentInfo `gorm:"not null;serializer:json" json:"info"`
Info types.CurrentInfo `gorm:"not null;default:'{}';serializer:json" json:"info"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -23,8 +23,8 @@ const (
type Setting struct {
ID uint `gorm:"primaryKey" json:"id"`
Key SettingKey `gorm:"not null;unique" json:"key"`
Value string `gorm:"not null" json:"value"`
Key SettingKey `gorm:"not null;default:'';unique" json:"key"`
Value string `gorm:"not null;default:''" json:"value"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -13,11 +13,11 @@ import (
type SSH struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null" json:"name"`
Host string `gorm:"not null" json:"host"`
Port uint `gorm:"not null" json:"port"`
Config ssh.ClientConfig `gorm:"not null;serializer:json" json:"config"`
Remark string `gorm:"not null" json:"remark"`
Name string `gorm:"not null;default:''" json:"name"`
Host string `gorm:"not null;default:''" json:"host"`
Port uint `gorm:"not null;default:0" json:"port"`
Config ssh.ClientConfig `gorm:"not null;default:'{}';serializer:json" json:"config"`
Remark string `gorm:"not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -13,10 +13,10 @@ const (
type Task struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null;index" json:"name"`
Name string `gorm:"not null;default:'';index" json:"name"`
Status TaskStatus `gorm:"not null;default:'waiting'" json:"status"`
Shell string `gorm:"not null" json:"-"`
Log string `gorm:"not null" json:"log"`
Shell string `gorm:"not null;default:''" json:"-"`
Log string `gorm:"not null;default:''" json:"log"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}

View File

@@ -8,9 +8,9 @@ import (
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
Username string `gorm:"not null;unique" json:"username"`
Password string `gorm:"not null" json:"password"`
Email string `gorm:"not null" json:"email"`
Username string `gorm:"not null;default:'';unique" json:"username"`
Password string `gorm:"not null;default:''" json:"password"`
Email string `gorm:"not null;default:''" json:"email"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`

View File

@@ -10,11 +10,11 @@ import (
type Website struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"not null;unique" json:"name"`
Name string `gorm:"not null;default:'';unique" json:"name"`
Status bool `gorm:"not null;default:true" json:"status"`
Path string `gorm:"not null" json:"path"`
Https bool `gorm:"not null" json:"https"`
Remark string `gorm:"not null" json:"remark"`
Path string `gorm:"not null;default:''" json:"path"`
Https bool `gorm:"not null;default:false" json:"https"`
Remark string `gorm:"not null;default:''" json:"remark"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`