node.go 2.2 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3
package node

import (
黄孟柱 已提交
4 5
	console_mysql "github.com/eolinker/goku-api-gateway/server/dao/console-mysql"
	entity "github.com/eolinker/goku-api-gateway/server/entity/console-entity"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8 9 10
//AddNode 新增节点信息
func AddNode(clusterID int, nodeName, nodeIP, nodePort, gatewayPath string, groupID int) (bool, map[string]interface{}, error) {
	return console_mysql.AddNode(clusterID, nodeName, nodeIP, nodePort, gatewayPath, groupID)
E
eoLinker API Management 已提交
11 12
}

Y
Your Name 已提交
13
//EditNode 修改节点
E
eoLinker API Management 已提交
14 15
func EditNode(nodeName, nodeIP, nodePort, gatewayPath string, nodeID, groupID int) (bool, string, error) {

Y
Your Name 已提交
16
	return console_mysql.EditNode(nodeName, nodeIP, nodePort, gatewayPath, nodeID, groupID)
E
eoLinker API Management 已提交
17 18
}

Y
Your Name 已提交
19
//DeleteNode 删除节点
E
eoLinker API Management 已提交
20 21 22 23
func DeleteNode(nodeID int) (bool, string, error) {
	return console_mysql.DeleteNode(nodeID)
}

Y
Your Name 已提交
24
//GetNodeInfo 获取节点信息
E
eoLinker API Management 已提交
25
func GetNodeInfo(nodeID int) (bool, *entity.Node, error) {
Y
Your Name 已提交
26
	b, node, e := console_mysql.GetNodeInfo(nodeID)
E
eoLinker API Management 已提交
27
	ResetNodeStatus(node)
Y
Your Name 已提交
28
	return b, node, e
E
eoLinker API Management 已提交
29 30
}

Y
Your Name 已提交
31 32 33
//GetNodeInfoByIPPort 获取节点信息
func GetNodeInfoByIPPort(ip string, port int) (bool, *entity.Node, error) {
	b, node, e := console_mysql.GetNodeByIPPort(ip, port)
E
eoLinker API Management 已提交
34
	ResetNodeStatus(node)
Y
Your Name 已提交
35
	return b, node, e
E
eoLinker API Management 已提交
36 37 38 39 40 41
}

// GetNodeList 获取节点列表
func GetNodeList(clusterID, groupID int, keyword string) (bool, []*entity.Node, error) {
	b, nodes, e := console_mysql.GetNodeList(clusterID, groupID, keyword)
	ResetNodeStatus(nodes...)
Y
Your Name 已提交
42
	return b, nodes, e
E
eoLinker API Management 已提交
43 44
}

Y
Your Name 已提交
45
//CheckIsExistRemoteAddr 节点IP查重
E
eoLinker API Management 已提交
46 47 48 49
func CheckIsExistRemoteAddr(nodeID int, nodeIP, nodePort string) bool {
	return console_mysql.CheckIsExistRemoteAddr(nodeID, nodeIP, nodePort)
}

Y
Your Name 已提交
50
//BatchDeleteNode 批量删除节点
E
eoLinker API Management 已提交
51 52 53 54 55 56 57 58 59 60
func BatchDeleteNode(nodeIDList string) (bool, string, error) {
	flag, nodeIDList, err := console_mysql.GetAvaliableNodeListFromNodeList(nodeIDList, 0)
	if !flag {
		return false, err.Error(), err
	} else if nodeIDList == "" {
		return false, "230013", err
	}
	return console_mysql.BatchDeleteNode(nodeIDList)
}

Y
Your Name 已提交
61
//BatchEditNodeGroup 批量修改节点分组
E
eoLinker API Management 已提交
62 63 64 65
func BatchEditNodeGroup(nodeIDList string, groupID int) (bool, string, error) {
	return console_mysql.BatchEditNodeGroup(nodeIDList, groupID)
}

Y
Your Name 已提交
66
//GetNodeIPList 获取节点IP列表
E
eoLinker API Management 已提交
67 68 69
func GetNodeIPList() (bool, []map[string]interface{}, error) {
	return console_mysql.GetNodeIPList()
}