uniugm/admin/apps/game/model/server.go

47 lines
1.8 KiB
Go
Raw Normal View History

2025-04-18 17:17:23 +08:00
package model
import (
"admin/internal/db"
2025-04-30 15:46:14 +08:00
"admin/internal/global"
2025-04-18 17:17:23 +08:00
"time"
)
func init() {
db.RegisterTableModels(Server{})
}
// Server 逻辑服
type Server struct {
2025-05-13 18:13:22 +08:00
ID int `gorm:"primarykey" readonly:"true"`
ProjectId int `gorm:"uniqueIndex:idx_server"`
ServerConfID string `gorm:"type:varchar(200);uniqueIndex:idx_server" name:"区服id" required:"true" uneditable:"true"`
Desc string `name:"描述"`
RunningStatus string `name:"进程运行状态" desc:"进程运行状态:未知、运行中、停止" readonly:"true" uneditable:"true"`
Ccu int `name:"实时在线" desc:"ccu" readonly:"true" uneditable:"true"`
TotalRoleCount int `name:"总角色数" desc:"" readonly:"true" uneditable:"true"`
TotalAccountCount int `name:"总账号数" desc:"" readonly:"true" uneditable:"true"`
IsServerDown bool `name:"停服维护中" desc:"" readonly:"true" uneditable:"true"`
2025-04-18 17:17:23 +08:00
// command_list接口服务器地址为空代表由由项目统一提供command_list.
// 取决于每个项目改造难度:
// 为空就代表项目要实现一个自己统一对外暴露的gm调用服务对内聚合、分发指令执行本后台执行指令只调用一次
// 不为空就代表command_list实现在各个逻辑服由本后台系统在执行指令时聚合、分发指令
// 调用各个逻辑服执行,本后台执行指令需要根据逻辑服数量调用;
2025-04-28 15:56:04 +08:00
//ApiAddr string
2025-04-18 17:17:23 +08:00
2025-04-28 15:56:04 +08:00
CreatedAt time.Time `readonly:"true"`
2025-04-24 20:39:31 +08:00
}
func (lm *Server) TableName() string {
return "server"
}
func (m *Server) GetId() int {
return m.ID
2025-04-18 17:17:23 +08:00
}
2025-04-30 15:46:14 +08:00
func (m *Server) ListByProjectId(projectId int) ([]*Server, error) {
list := make([]*Server, 0)
err := global.GLOB_DB.Where("project_id=?", projectId).Find(&list).Error
return list, err
}