修改数据库表

This commit is contained in:
bjdgyc 2021-07-19 15:15:29 +08:00
parent 8ff77626d0
commit e4f959cb69
5 changed files with 94 additions and 46 deletions

View File

@ -29,20 +29,20 @@ type ValData struct {
Note string `json:"note"` Note string `json:"note"`
} }
type Group struct { // type Group struct {
Id int `json:"id" xorm:"pk autoincr not null"` // Id int `json:"id" xorm:"pk autoincr not null"`
Name string `json:"name" xorm:"not null unique"` // Name string `json:"name" xorm:"not null unique"`
Note string `json:"note"` // Note string `json:"note"`
AllowLan bool `json:"allow_lan"` // AllowLan bool `json:"allow_lan"`
ClientDns []ValData `json:"client_dns"` // ClientDns []ValData `json:"client_dns"`
RouteInclude []ValData `json:"route_include"` // RouteInclude []ValData `json:"route_include"`
RouteExclude []ValData `json:"route_exclude"` // RouteExclude []ValData `json:"route_exclude"`
LinkAcl []GroupLinkAcl `json:"link_acl"` // LinkAcl []GroupLinkAcl `json:"link_acl"`
Bandwidth int `json:"bandwidth"` // 带宽限制 // Bandwidth int `json:"bandwidth"` // 带宽限制
Status int8 `json:"status"` // 1正常 // Status int8 `json:"status"` // 1正常
CreatedAt time.Time `json:"created_at"` // CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` // UpdatedAt time.Time `json:"updated_at"`
} // }
func GetGroupNames() []string { func GetGroupNames() []string {
var datas []Group var datas []Group

View File

@ -5,17 +5,17 @@ import (
"time" "time"
) )
type IpMap struct { // type IpMap struct {
Id int `json:"id" xorm:"pk autoincr not null"` // Id int `json:"id" xorm:"pk autoincr not null"`
IpAddr string `json:"ip_addr" xorm:"not null unique"` // IpAddr string `json:"ip_addr" xorm:"not null unique"`
MacAddr string `json:"mac_addr" xorm:"not null unique"` // MacAddr string `json:"mac_addr" xorm:"not null unique"`
Username string `json:"username"` // Username string `json:"username"`
Keep bool `json:"keep"` // 保留 ip-mac 绑定 // Keep bool `json:"keep"` // 保留 ip-mac 绑定
KeepTime time.Time `json:"keep_time"` // KeepTime time.Time `json:"keep_time"`
Note string `json:"note"` // 备注 // Note string `json:"note"` // 备注
LastLogin time.Time `json:"last_login"` // LastLogin time.Time `json:"last_login"`
UpdatedAt time.Time `json:"updated_at"` // UpdatedAt time.Time `json:"updated_at"`
} // }
func SetIpMap(v *IpMap) error { func SetIpMap(v *IpMap) error {
var err error var err error

View File

@ -10,12 +10,6 @@ const (
InstallData = "OK" 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 { type SettingSmtp struct {
Host string `json:"host"` Host string `json:"host"`
Port int `json:"port"` Port int `json:"port"`

54
server/dbdata/tables.go Normal file
View File

@ -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"`
}

View File

@ -10,21 +10,21 @@ import (
"github.com/xlzd/gotp" "github.com/xlzd/gotp"
) )
type User struct { // type User struct {
Id int `json:"id" xorm:"pk autoincr not null"` // Id int `json:"id" xorm:"pk autoincr not null"`
Username string `json:"username" storm:"not null unique"` // Username string `json:"username" storm:"not null unique"`
Nickname string `json:"nickname"` // Nickname string `json:"nickname"`
Email string `json:"email"` // Email string `json:"email"`
// Password string `json:"password"` // // Password string `json:"password"`
PinCode string `json:"pin_code"` // PinCode string `json:"pin_code"`
OtpSecret string `json:"otp_secret"` // OtpSecret string `json:"otp_secret"`
DisableOtp bool `json:"disable_otp"` // 禁用otp // DisableOtp bool `json:"disable_otp"` // 禁用otp
Groups []string `json:"groups"` // Groups []string `json:"groups"`
Status int8 `json:"status"` // 1正常 // Status int8 `json:"status"` // 1正常
SendEmail bool `json:"send_email"` // SendEmail bool `json:"send_email"`
CreatedAt time.Time `json:"created_at"` // CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"` // UpdatedAt time.Time `json:"updated_at"`
} // }
func SetUser(v *User) error { func SetUser(v *User) error {
var err error var err error