fix struct tags (#7)

This commit is contained in:
UUBulb 2024-11-16 20:57:03 +08:00 committed by GitHub
parent 8640cbbf42
commit 288e1b75e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 87 additions and 87 deletions

View File

@ -12,11 +12,11 @@ const (
type AlertRule struct {
Common
Name string `json:"name,omitempty"`
Name string `json:"name"`
RulesRaw string `json:"-"`
Enable *bool `json:"enable,omitempty"`
TriggerMode int `gorm:"default:0" json:"trigger_mode,omitempty"` // 触发模式: 0-始终触发(默认) 1-单次触发
NotificationGroupID uint64 `json:"notification_group_id,omitempty"` // 该报警规则所在的通知组
TriggerMode uint8 `gorm:"default:0" json:"trigger_mode"` // 触发模式: 0-始终触发(默认) 1-单次触发
NotificationGroupID uint64 `json:"notification_group_id"` // 该报警规则所在的通知组
FailTriggerTasksRaw string `gorm:"default:'[]'" json:"-"`
RecoverTriggerTasksRaw string `gorm:"default:'[]'" json:"-"`
Rules []Rule `gorm:"-" json:"rules"`

View File

@ -1,11 +1,11 @@
package model
type AlertRuleForm struct {
Name string `json:"name"`
Name string `json:"name" minLength:"1"`
Rules []Rule `json:"rules"`
FailTriggerTasks []uint64 `json:"fail_trigger_tasks"` // 失败时触发的任务id
RecoverTriggerTasks []uint64 `json:"recover_trigger_tasks"` // 恢复时触发的任务id
NotificationGroupID uint64 `json:"notification_group_id"`
TriggerMode int `json:"trigger_mode"`
Enable bool `json:"enable"`
TriggerMode uint8 `json:"trigger_mode" default:"0"`
Enable bool `json:"enable" validate:"optional"`
}

View File

@ -18,8 +18,8 @@ const (
type Config struct {
Debug bool `mapstructure:"debug" json:"debug,omitempty"` // debug模式开关
Language string `mapstructure:"language" json:"language,omitempty"` // 系统语言,默认 zh_CN
SiteName string `mapstructure:"site_name" json:"site_name,omitempty"`
Language string `mapstructure:"language" json:"language"` // 系统语言,默认 zh_CN
SiteName string `mapstructure:"site_name" json:"site_name"`
JWTSecretKey string `mapstructure:"jwt_secret_key" json:"jwt_secret_key,omitempty"`
AgentSecretKey string `mapstructure:"agent_secret_key" json:"agent_secret_key,omitempty"`
ListenPort uint `mapstructure:"listen_port" json:"listen_port,omitempty"`
@ -31,8 +31,8 @@ type Config struct {
// IP变更提醒
EnableIPChangeNotification bool `mapstructure:"enable_ip_change_notification" json:"enable_ip_change_notification,omitempty"`
IPChangeNotificationGroupID uint64 `mapstructure:"ip_change_notification_group_id" json:"ip_change_notification_group_id,omitempty"`
Cover uint8 `mapstructure:"cover" json:"cover,omitempty"` // 覆盖范围0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;
IPChangeNotificationGroupID uint64 `mapstructure:"ip_change_notification_group_id" json:"ip_change_notification_group_id"`
Cover uint8 `mapstructure:"cover" json:"cover"` // 覆盖范围0:提醒未被 IgnoredIPNotification 包含的所有服务器; 1:仅提醒被 IgnoredIPNotification 包含的服务器;
IgnoredIPNotification string `mapstructure:"ignored_ip_notification" json:"ignored_ip_notification,omitempty"` // 特定服务器IP多个服务器用逗号分隔
IgnoredIPNotificationServerIDs map[uint64]bool `mapstructure:"ignored_ip_notification_server_ids" json:"ignored_ip_notification_server_ids,omitempty"` // [ServerID] -> bool(值为true代表当前ServerID在特定服务器列表内

View File

@ -18,16 +18,16 @@ const (
type Cron struct {
Common
Name string `json:"name,omitempty"`
TaskType uint8 `gorm:"default:0" json:"task_type,omitempty"` // 0:计划任务 1:触发任务
Scheduler string `json:"scheduler,omitempty"` // 分钟 小时 天 月 星期
Name string `json:"name"`
TaskType uint8 `gorm:"default:0" json:"task_type"` // 0:计划任务 1:触发任务
Scheduler string `json:"scheduler"` // 分钟 小时 天 月 星期
Command string `json:"command,omitempty"`
Servers []uint64 `gorm:"-" json:"servers,omitempty"`
Servers []uint64 `gorm:"-" json:"servers"`
PushSuccessful bool `json:"push_successful,omitempty"` // 推送成功的通知
NotificationGroupID uint64 `json:"notification_group_id,omitempty"` // 指定通知方式的分组
NotificationGroupID uint64 `json:"notification_group_id"` // 指定通知方式的分组
LastExecutedAt time.Time `json:"last_executed_at,omitempty"` // 最后一次执行时间
LastResult bool `json:"last_result,omitempty"` // 最后一次执行结果
Cover uint8 `json:"cover,omitempty"` // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器 2:由触发该计划任务的服务器执行)
Cover uint8 `json:"cover"` // 计划任务覆盖范围 (0:仅覆盖特定服务器 1:仅忽略特定服务器 2:由触发该计划任务的服务器执行)
CronJobID cron.EntryID `gorm:"-" json:"cron_job_id,omitempty"`
ServersRaw string `json:"-"`

View File

@ -2,12 +2,12 @@ package model
type CronForm struct {
ID uint64 `json:"id,omitempty"`
TaskType uint8 `json:"task_type,omitempty"` // 0:计划任务 1:触发任务
Name string `json:"name,omitempty"`
TaskType uint8 `json:"task_type,omitempty" default:"0"` // 0:计划任务 1:触发任务
Name string `json:"name,omitempty" minLength:"1"`
Scheduler string `json:"scheduler,omitempty"`
Command string `json:"command,omitempty"`
Command string `json:"command,omitempty" validate:"optional"`
Servers []uint64 `json:"servers,omitempty"`
Cover uint8 `json:"cover,omitempty"`
PushSuccessful bool `json:"push_successful,omitempty"`
Cover uint8 `json:"cover,omitempty" default:"0"`
PushSuccessful bool `json:"push_successful,omitempty" validate:"optional"`
NotificationGroupID uint64 `json:"notification_group_id,omitempty"`
}

View File

@ -22,9 +22,9 @@ type DDNSProfile struct {
Common
EnableIPv4 *bool `json:"enable_ipv4,omitempty"`
EnableIPv6 *bool `json:"enable_ipv6,omitempty"`
MaxRetries uint64 `json:"max_retries,omitempty"`
Name string `json:"name,omitempty"`
Provider string `json:"provider,omitempty"`
MaxRetries uint64 `json:"max_retries"`
Name string `json:"name"`
Provider string `json:"provider"`
AccessID string `json:"access_id,omitempty"`
AccessSecret string `json:"access_secret,omitempty"`
WebhookURL string `json:"webhook_url,omitempty"`
@ -32,7 +32,7 @@ type DDNSProfile struct {
WebhookRequestType uint8 `json:"webhook_request_type,omitempty"`
WebhookRequestBody string `json:"webhook_request_body,omitempty"`
WebhookHeaders string `json:"webhook_headers,omitempty"`
Domains []string `json:"domains,omitempty" gorm:"-"`
Domains []string `json:"domains" gorm:"-"`
DomainsRaw string `json:"-"`
}

View File

@ -1,17 +1,17 @@
package model
type DDNSForm struct {
MaxRetries uint64 `json:"max_retries,omitempty"`
EnableIPv4 bool `json:"enable_ipv4,omitempty"`
EnableIPv6 bool `json:"enable_ipv6,omitempty"`
Name string `json:"name,omitempty"`
MaxRetries uint64 `json:"max_retries,omitempty" default:"3"`
EnableIPv4 bool `json:"enable_ipv4,omitempty" validate:"optional"`
EnableIPv6 bool `json:"enable_ipv6,omitempty" validate:"optional"`
Name string `json:"name,omitempty" minLength:"1"`
Provider string `json:"provider,omitempty"`
Domains []string `json:"domains,omitempty"`
AccessID string `json:"access_id,omitempty"`
AccessSecret string `json:"access_secret,omitempty"`
WebhookURL string `json:"webhook_url,omitempty"`
WebhookMethod uint8 `json:"webhook_method,omitempty"`
WebhookRequestType uint8 `json:"webhook_request_type,omitempty"`
WebhookRequestBody string `json:"webhook_request_body,omitempty"`
WebhookHeaders string `json:"webhook_headers,omitempty"`
AccessID string `json:"access_id,omitempty" validate:"optional"`
AccessSecret string `json:"access_secret,omitempty" validate:"optional"`
WebhookURL string `json:"webhook_url,omitempty" validate:"optional"`
WebhookMethod uint8 `json:"webhook_method,omitempty" validate:"optional" default:"1"`
WebhookRequestType uint8 `json:"webhook_request_type,omitempty" validate:"optional" default:"1"`
WebhookRequestBody string `json:"webhook_request_body,omitempty" validate:"optional"`
WebhookHeaders string `json:"webhook_headers,omitempty" validate:"optional"`
}

View File

@ -2,8 +2,8 @@ package model
type NAT struct {
Common
Name string
ServerID uint64
Host string
Domain string `gorm:"unique"`
Name string `json:"name"`
ServerID uint64 `json:"server_id"`
Host string `json:"host"`
Domain string `json:"domain" gorm:"unique"`
}

View File

@ -1,7 +1,7 @@
package model
type NATForm struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" minLength:"1"`
ServerID uint64 `json:"server_id,omitempty"`
Host string `json:"host,omitempty"`
Domain string `json:"domain,omitempty"`

View File

@ -32,12 +32,12 @@ type NotificationServerBundle struct {
type Notification struct {
Common
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
RequestMethod int `json:"request_method,omitempty"`
RequestType int `json:"request_type,omitempty"`
RequestHeader string `json:"request_header,omitempty" gorm:"type:longtext"`
RequestBody string `json:"request_body,omitempty" gorm:"type:longtext"`
Name string `json:"name"`
URL string `json:"url"`
RequestMethod uint8 `json:"request_method"`
RequestType uint8 `json:"request_type"`
RequestHeader string `json:"request_header" gorm:"type:longtext"`
RequestBody string `json:"request_body" gorm:"type:longtext"`
VerifyTLS *bool `json:"verify_tls,omitempty"`
}

View File

@ -1,12 +1,12 @@
package model
type NotificationForm struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" minLength:"1"`
URL string `json:"url,omitempty"`
RequestMethod int `json:"request_method,omitempty"`
RequestType int `json:"request_type,omitempty"`
RequestMethod uint8 `json:"request_method,omitempty"`
RequestType uint8 `json:"request_type,omitempty"`
RequestHeader string `json:"request_header,omitempty"`
RequestBody string `json:"request_body,omitempty"`
VerifyTLS bool `json:"verify_tls,omitempty"`
SkipCheck bool `json:"skip_check,omitempty"`
VerifyTLS bool `json:"verify_tls,omitempty" validate:"optional"`
SkipCheck bool `json:"skip_check,omitempty" validate:"optional"`
}

View File

@ -1,7 +1,7 @@
package model
type NotificationGroupForm struct {
Name string `json:"name"`
Name string `json:"name" minLength:"1"`
Notifications []uint64 `json:"notifications"`
}

View File

@ -17,8 +17,8 @@ type testSt struct {
url string
body string
header string
reqType int
reqMethod int
reqType uint8
reqMethod uint8
expectURL string
expectBody string
expectMethod string

View File

@ -14,16 +14,16 @@ import (
type Server struct {
Common
Name string `json:"name,omitempty"`
Name string `json:"name"`
UUID string `json:"uuid,omitempty" gorm:"unique"`
Note string `json:"note,omitempty"` // 管理员可见备注
PublicNote string `json:"public_note,omitempty"` // 公开备注
DisplayIndex int `json:"display_index,omitempty"` // 展示排序,越大越靠前
DisplayIndex int `json:"display_index"` // 展示排序,越大越靠前
HideForGuest bool `json:"hide_for_guest,omitempty"` // 对游客隐藏
EnableDDNS bool `json:"enable_ddns,omitempty"` // 启用DDNS
DDNSProfilesRaw string `gorm:"default:'[]';column:ddns_profiles_raw" json:"-"`
DDNSProfiles []uint64 `gorm:"-" json:"ddns_profiles,omitempty"` // DDNS配置
DDNSProfiles []uint64 `gorm:"-" json:"ddns_profiles"` // DDNS配置
Host *Host `gorm:"-" json:"host,omitempty"`
State *HostState `gorm:"-" json:"state,omitempty"`

View File

@ -20,10 +20,10 @@ type StreamServerData struct {
type ServerForm struct {
Name string `json:"name,omitempty"`
Note string `json:"note,omitempty"` // 管理员可见备注
PublicNote string `json:"public_note,omitempty"` // 公开备注
DisplayIndex int `json:"display_index,omitempty"` // 展示排序,越大越靠前
HideForGuest bool `json:"hide_for_guest,omitempty"` // 对游客隐藏
EnableDDNS bool `json:"enable_ddns,omitempty"` // 启用DDNS
Note string `json:"note,omitempty" validate:"optional"` // 管理员可见备注
PublicNote string `json:"public_note,omitempty" validate:"optional"` // 公开备注
DisplayIndex int `json:"display_index,omitempty" default:"0"` // 展示排序,越大越靠前
HideForGuest bool `json:"hide_for_guest,omitempty" validate:"optional"` // 对游客隐藏
EnableDDNS bool `json:"enable_ddns,omitempty" validate:"optional"` // 启用DDNS
DDNSProfiles []uint64 `gorm:"-" json:"ddns_profiles,omitempty"` // DDNS配置
}

View File

@ -1,7 +1,7 @@
package model
type ServerGroupForm struct {
Name string `json:"name"`
Name string `json:"name" minLength:"1"`
Servers []uint64 `json:"servers"`
}

View File

@ -63,8 +63,8 @@ type Service struct {
FailTriggerTasks []uint64 `gorm:"-" json:"fail_trigger_tasks"` // 失败时执行的触发任务id
RecoverTriggerTasks []uint64 `gorm:"-" json:"recover_trigger_tasks"` // 恢复时执行的触发任务id
MinLatency float32 `json:"min_latency,omitempty"`
MaxLatency float32 `json:"max_latency,omitempty"`
MinLatency float32 `json:"min_latency"`
MaxLatency float32 `json:"max_latency"`
LatencyNotify bool `json:"latency_notify,omitempty"`
SkipServers map[uint64]bool `gorm:"-" json:"skip_servers"`

View File

@ -3,17 +3,17 @@ package model
import "time"
type ServiceForm struct {
Name string `json:"name,omitempty"`
Name string `json:"name,omitempty" minLength:"1"`
Target string `json:"target,omitempty"`
Type uint8 `json:"type,omitempty"`
Cover uint8 `json:"cover,omitempty"`
Notify bool `json:"notify,omitempty"`
Notify bool `json:"notify,omitempty" validate:"optional"`
Duration uint64 `json:"duration,omitempty"`
MinLatency float32 `json:"min_latency,omitempty"`
MaxLatency float32 `json:"max_latency,omitempty"`
LatencyNotify bool `json:"latency_notify,omitempty"`
EnableTriggerTask bool `json:"enable_trigger_task,omitempty"`
EnableShowInService bool `json:"enable_show_in_service,omitempty"`
MinLatency float32 `json:"min_latency,omitempty" default:"0.0"`
MaxLatency float32 `json:"max_latency,omitempty" default:"0.0"`
LatencyNotify bool `json:"latency_notify,omitempty" validate:"optional"`
EnableTriggerTask bool `json:"enable_trigger_task,omitempty" validate:"optional"`
EnableShowInService bool `json:"enable_show_in_service,omitempty" validate:"optional"`
FailTriggerTasks []uint64 `json:"fail_trigger_tasks,omitempty"`
RecoverTriggerTasks []uint64 `json:"recover_trigger_tasks,omitempty"`
SkipServers map[uint64]bool `json:"skip_servers,omitempty"`

View File

@ -1,16 +1,16 @@
package model
type SettingForm struct {
CustomNameservers string `json:"custom_nameservers,omitempty"`
IgnoredIPNotification string `json:"ignored_ip_notification,omitempty"`
CustomNameservers string `json:"custom_nameservers,omitempty" validate:"optional"`
IgnoredIPNotification string `json:"ignored_ip_notification,omitempty" validate:"optional"`
IPChangeNotificationGroupID uint64 `json:"ip_change_notification_group_id,omitempty"` // IP变更提醒的通知组
Cover uint8 `json:"cover,omitempty"`
SiteName string `json:"site_name,omitempty"`
Language string `json:"language,omitempty"`
InstallHost string `json:"install_host,omitempty"`
CustomCode string `json:"custom_code,omitempty"`
CustomCodeDashboard string `json:"custom_code_dashboard,omitempty"`
InstallHost string `json:"install_host,omitempty" validate:"optional"`
CustomCode string `json:"custom_code,omitempty" validate:"optional"`
CustomCodeDashboard string `json:"custom_code_dashboard,omitempty" validate:"optional"`
EnableIPChangeNotification bool `json:"enable_ip_change_notification,omitempty"`
EnablePlainIPInNotification bool `json:"enable_plain_ip_in_notification,omitempty"`
EnableIPChangeNotification bool `json:"enable_ip_change_notification,omitempty" validate:"optional"`
EnablePlainIPInNotification bool `json:"enable_plain_ip_in_notification,omitempty" validate:"optional"`
}

View File

@ -2,7 +2,7 @@ package model
type Transfer struct {
Common
ServerID uint64
In uint64
Out uint64
ServerID uint64 `json:"server_id"`
In uint64 `json:"in"`
Out uint64 `json:"out"`
}