47 lines
2.0 KiB
Go
47 lines
2.0 KiB
Go
package model
|
|
|
|
// Node 节点信息
|
|
type Node struct {
|
|
NodeId int64 `xorm:"not null pk autoincr INT(11)" json:"nodeId"`
|
|
NodeGuid string `xorm:"varchar(100) index" json:"nodeGuid"`
|
|
NodeName string `xorm:"varchar(100)" json:"nodeName"`
|
|
NodeType int `xorm:"not null SMALLINT default 0" json:"nodeType"`
|
|
NodeStatus int `xorm:"not null SMALLINT default 0" json:"nodeStatus"`
|
|
Platform string `xorm:"varchar(100)" json:"platform,omitempty"`
|
|
PlatformVersion string `xorm:"varchar(100)" json:"platformVersion,omitempty"`
|
|
CPU string `xorm:"varchar(1000)" json:"cpu,omitempty"`
|
|
MemTotal uint64 `xorm:"BIGINT" json:"memTotal,omitempty"`
|
|
DiskTotal uint64 `xorm:"BIGINT" json:"diskTotal,omitempty"`
|
|
SwapTotal uint64 `xorm:"BIGINT" json:"swapTotal,omitempty"`
|
|
Arch string `xorm:"varchar(1000)" json:"arch,omitempty"`
|
|
Virtualization string `xorm:"varchar(1000)" json:"virtualization,omitempty"`
|
|
BootTime uint64 `xorm:"BIGINT" json:"bootTime,omitempty"`
|
|
IP string `xorm:"varchar(100)" json:"ip"`
|
|
IsGpu bool `xorm:"TINYINT(1) default 0" json:"isGpu"`
|
|
IsTaskExecute bool `xorm:"TINYINT(1) default 0" json:"isTaskExecute"`
|
|
CountryCode string `xorm:"varchar(100)" json:"countryCode,omitempty"`
|
|
Version string `xorm:"varchar(100)" json:"version,omitempty"`
|
|
CreateAt int64 `xorm:"created" json:"createAt"`
|
|
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
|
}
|
|
|
|
func GetLightWeight(modelId int64) []Node {
|
|
list := make([]Node, 0)
|
|
err := DB.Table("node").Alias("n").Join("inner", []string{"model_issue", "m"}, "m.node_id = n.node_id").
|
|
Where("n.is_task_execute = 1").And("n.is_gpu = 1").And("m.model_id = ?", modelId).Find(&list)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return list
|
|
}
|
|
|
|
func GetAllNode(modelId int64) []Node {
|
|
list := make([]Node, 0)
|
|
err := DB.Table("node").Alias("n").Join("inner", []string{"model_issue", "m"}, "m.node_id = n.node_id").
|
|
Where("m.model_id = ?", modelId).Find(&list)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return list
|
|
}
|