增加webssh及数据库查询

This commit is contained in:
meilin.huang
2021-01-08 15:37:32 +08:00
parent 111612b7f2
commit 4c2e6b6155
60 changed files with 4347 additions and 2222 deletions

View File

@@ -1,13 +1,14 @@
package models
import (
"github.com/astaxie/beego/orm"
"mayfly-go/base"
"mayfly-go/base/model"
"mayfly-go/controllers/vo"
"github.com/beego/beego/v2/client/orm"
)
type Machine struct {
base.Model
model.Model
Name string `orm:"column(name)"`
// IP地址
Ip string `orm:"column(ip)" json:"ip"`
@@ -25,7 +26,7 @@ func init() {
func GetMachineById(id uint64) *Machine {
machine := new(Machine)
machine.Id = id
err := base.GetBy(machine)
err := model.GetBy(machine)
if err != nil {
return nil
}
@@ -33,13 +34,13 @@ func GetMachineById(id uint64) *Machine {
}
// 分页获取机器信息列表
func GetMachineList(pageParam *base.PageParam) base.PageResult {
func GetMachineList(pageParam *model.PageParam) model.PageResult {
m := new([]Machine)
querySetter := base.QuerySetter(new(Machine)).OrderBy("-Id")
return base.GetPage(querySetter, pageParam, m, new([]vo.MachineVO))
querySetter := model.QuerySetter(new(Machine)).OrderBy("-Id")
return model.GetPage(querySetter, pageParam, m, new([]vo.MachineVO))
}
// 获取所有需要监控的机器信息列表
func GetNeedMonitorMachine() *[]orm.Params {
return base.GetListBySql("SELECT id FROM t_machine WHERE need_monitor = 1")
return model.GetListBySql("SELECT id FROM t_machine WHERE need_monitor = 1")
}