refactor: 重构服务器冠名逻辑至独立表
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-04-10 19:36:59 +08:00
parent ee3f25438f
commit 90f1447d48
9 changed files with 343 additions and 147 deletions

View File

@@ -1,39 +1,40 @@
package model
import (
"blazing/cool"
"blazing/cool/coolconfig"
)
const TableNameServerList = "server_list"
// 服务器设置天气地图|地图是否显示其他人,设置异色概率|ip
// ServerList mapped from table <server_list>
type ServerList struct {
*cool.Model
coolconfig.ServerList
//isonline
IsOnline uint8 `gorm:"column:isonline;default:0;comment:'是否在线'" json:"isonline"`
}
// TableName ServerList's table name
func (*ServerList) TableName() string {
return TableNameServerList
}
// GroupName ServerList's table group
func (*ServerList) GroupName() string {
return "default"
}
// NewServerList create a new ServerList
func NewServerList() *ServerList {
return &ServerList{
Model: cool.NewModel(),
}
}
// init 创建表
func init() {
cool.CreateTable(&ServerList{})
}
package model
import (
"blazing/cool"
"blazing/cool/coolconfig"
)
const TableNameServerList = "server_list"
// 服务器设置天气地图|地图是否显示其他人,设置异色概率|ip
// ServerList mapped from table <server_list>
type ServerList struct {
*cool.Model
coolconfig.ServerList
ServerShow *ServerShow `orm:"with:server_id=online_id" json:"server_show,omitempty"`
// isonline
IsOnline uint8 `gorm:"column:isonline;default:0;comment:'是否在线'" json:"isonline"`
}
// TableName ServerList's table name
func (*ServerList) TableName() string {
return TableNameServerList
}
// GroupName ServerList's table group
func (*ServerList) GroupName() string {
return "default"
}
// NewServerList create a new ServerList
func NewServerList() *ServerList {
return &ServerList{
Model: cool.NewModel(),
}
}
// init 创建表
func init() {
cool.CreateTable(&ServerList{})
}

View File

@@ -0,0 +1,39 @@
package model
import (
"blazing/cool"
"time"
)
const TableNameServerShow = "server_show"
// ServerShow 绑定服务器展示信息(冠名、属主、到期时间)。
type ServerShow struct {
*cool.Model
ServerID uint32 `gorm:"column:server_id;comment:'服务器ID';uniqueIndex" json:"server_id"`
Name string `gorm:"comment:'服务器展示名'" json:"name"`
Owner uint32 `gorm:"comment:'服务器属主'" json:"owner"`
ExpireTime time.Time `gorm:"column:expire_time;default:0;comment:'展示到期时间'" json:"expire_time"`
}
// TableName ServerShow's table name
func (*ServerShow) TableName() string {
return TableNameServerShow
}
// GroupName ServerShow's table group
func (*ServerShow) GroupName() string {
return "default"
}
// NewServerShow create a new ServerShow
func NewServerShow() *ServerShow {
return &ServerShow{
Model: cool.NewModel(),
}
}
// init 创建表
func init() {
cool.CreateTable(&ServerShow{})
}