tables.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package dbdata
  2. import (
  3. "encoding/json"
  4. "time"
  5. )
  6. type Group struct {
  7. Id int `json:"id" xorm:"pk autoincr not null"`
  8. Name string `json:"name" xorm:"varchar(60) not null unique"`
  9. Note string `json:"note" xorm:"varchar(255)"`
  10. AllowLan bool `json:"allow_lan" xorm:"Bool"`
  11. ClientDns []ValData `json:"client_dns" xorm:"Text"`
  12. RouteInclude []ValData `json:"route_include" xorm:"Text"`
  13. RouteExclude []ValData `json:"route_exclude" xorm:"Text"`
  14. DsExcludeDomains string `json:"ds_exclude_domains" xorm:"Text"`
  15. DsIncludeDomains string `json:"ds_include_domains" xorm:"Text"`
  16. LinkAcl []GroupLinkAcl `json:"link_acl" xorm:"Text"`
  17. Bandwidth int `json:"bandwidth" xorm:"Int"` // 带宽限制
  18. Auth map[string]interface{} `json:"auth" xorm:"not null default '{}' varchar(500)"` // 认证方式
  19. Status int8 `json:"status" xorm:"Int"` // 1正常
  20. CreatedAt time.Time `json:"created_at" xorm:"DateTime created"`
  21. UpdatedAt time.Time `json:"updated_at" xorm:"DateTime updated"`
  22. }
  23. type User struct {
  24. Id int `json:"id" xorm:"pk autoincr not null"`
  25. Username string `json:"username" xorm:"varchar(60) not null unique"`
  26. Nickname string `json:"nickname" xorm:"varchar(255)"`
  27. Email string `json:"email" xorm:"varchar(255)"`
  28. // Password string `json:"password"`
  29. PinCode string `json:"pin_code" xorm:"varchar(32)"`
  30. LimitTime *time.Time `json:"limittime,omitempty" xorm:"Datetime limittime"` // 值为null时,前端不显示
  31. OtpSecret string `json:"otp_secret" xorm:"varchar(255)"`
  32. DisableOtp bool `json:"disable_otp" xorm:"Bool"` // 禁用otp
  33. Groups []string `json:"groups" xorm:"Text"`
  34. Status int8 `json:"status" xorm:"Int"` // 1正常
  35. SendEmail bool `json:"send_email" xorm:"Bool"`
  36. CreatedAt time.Time `json:"created_at" xorm:"DateTime created"`
  37. UpdatedAt time.Time `json:"updated_at" xorm:"DateTime updated"`
  38. }
  39. type UserActLog struct {
  40. Id int `json:"id" xorm:"pk autoincr not null"`
  41. Username string `json:"username" xorm:"varchar(60)"`
  42. GroupName string `json:"group_name" xorm:"varchar(60)"`
  43. IpAddr string `json:"ip_addr" xorm:"varchar(32)"`
  44. RemoteAddr string `json:"remote_addr" xorm:"varchar(32)"`
  45. Os uint8 `json:"os" xorm:"not null default 0 Int"`
  46. Client uint8 `json:"client" xorm:"not null default 0 Int"`
  47. Version string `json:"version" xorm:"varchar(15)"`
  48. DeviceType string `json:"device_type" xorm:"varchar(128) not null default ''"`
  49. PlatformVersion string `json:"platform_version" xorm:"varchar(128) not null default ''"`
  50. Status uint8 `json:"status" xorm:"not null default 0 Int"`
  51. Info string `json:"info" xorm:"varchar(255) not null default ''"` // 详情
  52. CreatedAt time.Time `json:"created_at" xorm:"DateTime created"`
  53. }
  54. type Setting struct {
  55. Id int `json:"id" xorm:"pk autoincr not null"`
  56. Name string `json:"name" xorm:"varchar(60) not null unique"`
  57. Data json.RawMessage `json:"data" xorm:"Text"`
  58. UpdatedAt time.Time `json:"updated_at" xorm:"DateTime updated"`
  59. }
  60. type AccessAudit struct {
  61. Id int `json:"id" xorm:"pk autoincr not null"`
  62. Username string `json:"username" xorm:"varchar(60) not null"`
  63. Protocol uint8 `json:"protocol" xorm:"not null"`
  64. Src string `json:"src" xorm:"varchar(60) not null"`
  65. SrcPort uint16 `json:"src_port" xorm:"not null"`
  66. Dst string `json:"dst" xorm:"varchar(60) not null"`
  67. DstPort uint16 `json:"dst_port" xorm:"not null"`
  68. AccessProto uint8 `json:"access_proto" xorm:"default 0"` // 访问协议
  69. Info string `json:"info" xorm:"varchar(255) not null default ''"` // 详情
  70. CreatedAt time.Time `json:"created_at" xorm:"DateTime"`
  71. }
  72. type Policy struct {
  73. Id int `json:"id" xorm:"pk autoincr not null"`
  74. Username string `json:"username" xorm:"varchar(60) not null unique"`
  75. AllowLan bool `json:"allow_lan" xorm:"Bool"`
  76. ClientDns []ValData `json:"client_dns" xorm:"Text"`
  77. RouteInclude []ValData `json:"route_include" xorm:"Text"`
  78. RouteExclude []ValData `json:"route_exclude" xorm:"Text"`
  79. DsExcludeDomains string `json:"ds_exclude_domains" xorm:"Text"`
  80. DsIncludeDomains string `json:"ds_include_domains" xorm:"Text"`
  81. Status int8 `json:"status" xorm:"Int"` // 1正常 0 禁用
  82. CreatedAt time.Time `json:"created_at" xorm:"DateTime created"`
  83. UpdatedAt time.Time `json:"updated_at" xorm:"DateTime updated"`
  84. }
  85. type StatsOnline struct {
  86. Id int `json:"id" xorm:"pk autoincr not null"`
  87. Num int `json:"num" xorm:"Int"`
  88. NumGroups string `json:"num_groups" xorm:"varchar(500) not null"`
  89. CreatedAt time.Time `json:"created_at" xorm:"DateTime created index"`
  90. }
  91. type StatsNetwork struct {
  92. Id int `json:"id" xorm:"pk autoincr not null"`
  93. Up uint32 `json:"up" xorm:"Int"`
  94. Down uint32 `json:"down" xorm:"Int"`
  95. UpGroups string `json:"up_groups" xorm:"varchar(500) not null"`
  96. DownGroups string `json:"down_groups" xorm:"varchar(500) not null"`
  97. CreatedAt time.Time `json:"created_at" xorm:"DateTime created index"`
  98. }
  99. type StatsCpu struct {
  100. Id int `json:"id" xorm:"pk autoincr not null"`
  101. Percent float64 `json:"percent" xorm:"Float"`
  102. CreatedAt time.Time `json:"created_at" xorm:"DateTime created index"`
  103. }
  104. type StatsMem struct {
  105. Id int `json:"id" xorm:"pk autoincr not null"`
  106. Percent float64 `json:"percent" xorm:"Float"`
  107. CreatedAt time.Time `json:"created_at" xorm:"DateTime created index"`
  108. }