diff --git a/server/dbdata/group.go b/server/dbdata/group.go index 900902f..fe7bcda 100644 --- a/server/dbdata/group.go +++ b/server/dbdata/group.go @@ -29,20 +29,20 @@ type ValData struct { Note string `json:"note"` } -type Group struct { - Id int `json:"id" xorm:"pk autoincr not null"` - Name string `json:"name" xorm:"not null unique"` - Note string `json:"note"` - AllowLan bool `json:"allow_lan"` - ClientDns []ValData `json:"client_dns"` - RouteInclude []ValData `json:"route_include"` - RouteExclude []ValData `json:"route_exclude"` - LinkAcl []GroupLinkAcl `json:"link_acl"` - Bandwidth int `json:"bandwidth"` // 带宽限制 - Status int8 `json:"status"` // 1正常 - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` -} +// type Group struct { +// Id int `json:"id" xorm:"pk autoincr not null"` +// Name string `json:"name" xorm:"not null unique"` +// Note string `json:"note"` +// AllowLan bool `json:"allow_lan"` +// ClientDns []ValData `json:"client_dns"` +// RouteInclude []ValData `json:"route_include"` +// RouteExclude []ValData `json:"route_exclude"` +// LinkAcl []GroupLinkAcl `json:"link_acl"` +// Bandwidth int `json:"bandwidth"` // 带宽限制 +// Status int8 `json:"status"` // 1正常 +// CreatedAt time.Time `json:"created_at"` +// UpdatedAt time.Time `json:"updated_at"` +// } func GetGroupNames() []string { var datas []Group diff --git a/server/dbdata/ip_map.go b/server/dbdata/ip_map.go index 7e9d05f..98c955a 100644 --- a/server/dbdata/ip_map.go +++ b/server/dbdata/ip_map.go @@ -5,17 +5,17 @@ import ( "time" ) -type IpMap struct { - Id int `json:"id" xorm:"pk autoincr not null"` - IpAddr string `json:"ip_addr" xorm:"not null unique"` - MacAddr string `json:"mac_addr" xorm:"not null unique"` - Username string `json:"username"` - Keep bool `json:"keep"` // 保留 ip-mac 绑定 - KeepTime time.Time `json:"keep_time"` - Note string `json:"note"` // 备注 - LastLogin time.Time `json:"last_login"` - UpdatedAt time.Time `json:"updated_at"` -} +// type IpMap struct { +// Id int `json:"id" xorm:"pk autoincr not null"` +// IpAddr string `json:"ip_addr" xorm:"not null unique"` +// MacAddr string `json:"mac_addr" xorm:"not null unique"` +// Username string `json:"username"` +// Keep bool `json:"keep"` // 保留 ip-mac 绑定 +// KeepTime time.Time `json:"keep_time"` +// Note string `json:"note"` // 备注 +// LastLogin time.Time `json:"last_login"` +// UpdatedAt time.Time `json:"updated_at"` +// } func SetIpMap(v *IpMap) error { var err error diff --git a/server/dbdata/setting.go b/server/dbdata/setting.go index bd3670e..1114b4e 100644 --- a/server/dbdata/setting.go +++ b/server/dbdata/setting.go @@ -10,12 +10,6 @@ const ( InstallData = "OK" ) -type Setting struct { - Id int `json:"id" xorm:"pk autoincr not null"` - Name string `json:"name" xorm:"not null unique"` - Data string `json:"data" xorm:"Text"` -} - type SettingSmtp struct { Host string `json:"host"` Port int `json:"port"` diff --git a/server/dbdata/tables.go b/server/dbdata/tables.go new file mode 100644 index 0000000..202e590 --- /dev/null +++ b/server/dbdata/tables.go @@ -0,0 +1,54 @@ +package dbdata + +import ( + "time" +) + +type Group struct { + Id int `json:"id" xorm:"pk autoincr not null"` + Name string `json:"name" xorm:"varchar(255) not null index(idx_code) unique"` + Note string `json:"note" xorm:"varchar(255)"` + AllowLan bool `json:"allow_lan" xorm:"Bool"` + ClientDns []ValData `json:"client_dns" xorm:"Text"` + RouteInclude []ValData `json:"route_include" xorm:"Text"` + RouteExclude []ValData `json:"route_exclude" xorm:"Text"` + LinkAcl []GroupLinkAcl `json:"link_acl" xorm:"Text"` + Bandwidth int `json:"bandwidth" xorm:"Int"` // 带宽限制 + Status int8 `json:"status" xorm:"Int"` // 1正常 + CreatedAt time.Time `json:"created_at" xorm:"DateTime"` + UpdatedAt time.Time `json:"updated_at" xorm:"DateTime"` +} + +type User struct { + Id int `json:"id" xorm:"pk autoincr not null"` + Username string `json:"username" xorm:"varchar(255) not null index(idx_code) unique"` + Nickname string `json:"nickname" xorm:"varchar(255)"` + Email string `json:"email" xorm:"varchar(255)"` + // Password string `json:"password"` + PinCode string `json:"pin_code" xorm:"varchar(255)"` + OtpSecret string `json:"otp_secret" xorm:"varchar(255)"` + DisableOtp bool `json:"disable_otp" xorm:"Bool"` // 禁用otp + Groups []string `json:"groups" xorm:"Text"` + Status int8 `json:"status" xorm:"Int"` // 1正常 + SendEmail bool `json:"send_email" xorm:"Bool"` + CreatedAt time.Time `json:"created_at" xorm:"DateTime"` + UpdatedAt time.Time `json:"updated_at" xorm:"DateTime"` +} + +type IpMap struct { + Id int `json:"id" xorm:"pk autoincr not null"` + IpAddr string `json:"ip_addr" xorm:"Text"` + MacAddr string `json:"mac_addr" xorm:"varchar(32) index(idx_macaddr)"` + Username string `json:"username" xorm:"varchar(255)"` + Keep bool `json:"keep" xorm:"Bool"` // 保留 ip-mac 绑定 + KeepTime time.Time `json:"keep_time" xorm:"DateTime"` + Note string `json:"note" xorm:"varchar(255)"` // 备注 + LastLogin time.Time `json:"last_login" xorm:"DateTime"` + UpdatedAt time.Time `json:"updated_at" xorm:"DateTime"` +} + +type Setting struct { + Id int `json:"id" xorm:"pk autoincr not null"` + Name string `json:"name" xorm:"not null unique"` + Data string `json:"data" xorm:"Text"` +} diff --git a/server/dbdata/user.go b/server/dbdata/user.go index 645817b..5fbb2d7 100644 --- a/server/dbdata/user.go +++ b/server/dbdata/user.go @@ -10,21 +10,21 @@ import ( "github.com/xlzd/gotp" ) -type User struct { - Id int `json:"id" xorm:"pk autoincr not null"` - Username string `json:"username" storm:"not null unique"` - Nickname string `json:"nickname"` - Email string `json:"email"` - // Password string `json:"password"` - PinCode string `json:"pin_code"` - OtpSecret string `json:"otp_secret"` - DisableOtp bool `json:"disable_otp"` // 禁用otp - Groups []string `json:"groups"` - Status int8 `json:"status"` // 1正常 - SendEmail bool `json:"send_email"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` -} +// type User struct { +// Id int `json:"id" xorm:"pk autoincr not null"` +// Username string `json:"username" storm:"not null unique"` +// Nickname string `json:"nickname"` +// Email string `json:"email"` +// // Password string `json:"password"` +// PinCode string `json:"pin_code"` +// OtpSecret string `json:"otp_secret"` +// DisableOtp bool `json:"disable_otp"` // 禁用otp +// Groups []string `json:"groups"` +// Status int8 `json:"status"` // 1正常 +// SendEmail bool `json:"send_email"` +// CreatedAt time.Time `json:"created_at"` +// UpdatedAt time.Time `json:"updated_at"` +// } func SetUser(v *User) error { var err error