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

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

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

type Info struct {
Y
Your Name 已提交
18 19 20 21 22 23 24 25 26 27
	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"`
E
eoLinker API Management 已提交
28 29 30
}

func ReadInfo(balance *entity.Balance) *Info {
Y
Your Name 已提交
31
	info := &Info{
E
eoLinker API Management 已提交
32 33 34 35
		Name:          balance.Name,
		ServiceName:   balance.ServiceName,
		ServiceType:   balance.ServiceType,
		ServiceDriver: balance.ServiceDriver,
Y
Your Name 已提交
36
		AppName:       balance.AppName,
E
eoLinker API Management 已提交
37 38 39 40 41 42
		Static:        balance.Static,
		StaticCluster: nil,
		Desc:          balance.Desc,
		CreateTime:    balance.CreateTime,
		UpdateTime:    balance.UpdateTime,
	}
Y
Your Name 已提交
43
	json.Unmarshal([]byte(balance.StaticCluster), &info.StaticCluster)
E
eoLinker API Management 已提交
44
	return info
Y
Your Name 已提交
45
}