param.go 1.6 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4
package balance

import (
	"encoding/json"
Y
Your Name 已提交
5

黄孟柱 已提交
6
	entity "github.com/eolinker/goku-api-gateway/server/entity/balance-entity-service"
E
eoLinker API Management 已提交
7 8
)

Y
Your Name 已提交
9
//Param 负载参数
E
eoLinker API Management 已提交
10
type Param struct {
Y
Your Name 已提交
11 12 13 14
	Name          string `opt:"balanceName,require"`
	ServiceName   string `opt:"serviceName,require"`
	AppName       string `opt:"appName"`
	Static        string `opt:"static"`
E
eoLinker API Management 已提交
15
	StaticCluster string `opt:"staticCluster"`
Y
Your Name 已提交
16
	Desc          string `opt:"balanceDesc"`
E
eoLinker API Management 已提交
17 18
}

Y
Your Name 已提交
19
//Info 负载信息
E
eoLinker API Management 已提交
20
type Info struct {
Y
Your Name 已提交
21 22 23 24 25 26 27 28 29 30
	Name          string            `json:"balanceName"`
	ServiceName   string            `json:"serviceName"`
	ServiceType   string            `json:"serviceType"`
	ServiceDriver string            `json:"serviceDriver"`
	AppName       string            `json:"appName"`
	Static        string            `json:"static"`
	StaticCluster map[string]string `json:"staticCluster"`
	Desc          string            `json:"balanceDesc"`
	CreateTime    string            `json:"createTime"`
	UpdateTime    string            `json:"updateTime"`
Y
Your Name 已提交
31
	CanDelete     int               `json:"canDelete"`
E
eoLinker API Management 已提交
32 33
}

Y
Your Name 已提交
34
//ReadInfo 读取负载信息
E
eoLinker API Management 已提交
35
func ReadInfo(balance *entity.Balance) *Info {
Y
Your Name 已提交
36
	info := &Info{
E
eoLinker API Management 已提交
37 38 39 40
		Name:          balance.Name,
		ServiceName:   balance.ServiceName,
		ServiceType:   balance.ServiceType,
		ServiceDriver: balance.ServiceDriver,
Y
Your Name 已提交
41
		AppName:       balance.AppName,
E
eoLinker API Management 已提交
42 43 44 45 46
		Static:        balance.Static,
		StaticCluster: nil,
		Desc:          balance.Desc,
		CreateTime:    balance.CreateTime,
		UpdateTime:    balance.UpdateTime,
Y
Your Name 已提交
47
		CanDelete:     balance.CanDelete,
E
eoLinker API Management 已提交
48
	}
Y
Your Name 已提交
49
	json.Unmarshal([]byte(balance.StaticCluster), &info.StaticCluster)
E
eoLinker API Management 已提交
50
	return info
Y
Your Name 已提交
51
}