package data_manage

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

// EdbTerminal 指标终端
type EdbTerminal struct {
	TerminalId   int       `orm:"column(terminal_id);pk"`
	Source       int       `orm:"column(source)" description:"指标来源类型"`
	Name         string    `description:"终端别名"`
	TerminalCode string    `description:"终端编码，用于配置在机器上"`
	ServerUrl    string    `description:"终端地址"`
	Num          int       `description:"终端最大指标数"`
	ModifyTime   time.Time `description:"修改时间"`
	CreateTime   time.Time `description:"创建时间"`
}

// GetEdbTerminalListBySource 根据指标来源类型获取所有的终端列表
func GetEdbTerminalListBySource(source int) (items []*EdbTerminal, err error) {
	o := orm.NewOrmUsingDB("data")
	sql := ` SELECT *  FROM edb_terminal WHERE source = ? ORDER BY terminal_id ASC `
	_, err = o.Raw(sql, source).QueryRows(&items)
	return
}
