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-06-09 13:50:00 +08:00
|
|
|
|
"admin/internal/model/dto"
|
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:"描述"`
|
2025-06-06 18:30:12 +08:00
|
|
|
|
ClientConnAddr string `name:"客户端连接地址" desc:"填 公网ip:公网端口" required:"true"`
|
2025-06-09 13:50:00 +08:00
|
|
|
|
RunningStatus string `name:"进程运行状态" desc:"进程运行状态:未知、运行中、停止" readonly:"true" uneditable:"true" type:"tagStatus" choices:"GetRunningStatusChoices"`
|
2025-05-13 18:13:22 +08:00
|
|
|
|
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"`
|
2025-06-09 13:50:00 +08:00
|
|
|
|
IsServerDown bool `name:"停服维护中" desc:"" readonly:"true" uneditable:"true" type:"tagStatus" choices:"GetServerDownStatusChoices"`
|
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-05-15 17:30:33 +08:00
|
|
|
|
UpdatedAt 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
|
|
|
|
|
2025-05-19 17:51:09 +08:00
|
|
|
|
func (m *Server) GetShowKey() string {
|
|
|
|
|
return m.ServerConfID
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2025-06-09 13:50:00 +08:00
|
|
|
|
|
|
|
|
|
func (m *Server) GetRunningStatusChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
|
|
|
|
return []*dto.CommonDtoFieldChoice{
|
|
|
|
|
{Desc: "失联", Value: "失联", Type: 3}, // type: 0:plain 1:primary 2:success 3:info 4:warning 5:danger
|
|
|
|
|
{Desc: "运行中", Value: "运行中", Type: 2},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Server) GetServerDownStatusChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
|
|
|
|
return []*dto.CommonDtoFieldChoice{
|
|
|
|
|
{Desc: "否", Value: false, Type: 3}, // type: 0:plain 1:primary 2:success 3:info 4:warning 5:danger
|
|
|
|
|
{Desc: "是", Value: true, Type: 2},
|
|
|
|
|
}
|
|
|
|
|
}
|