param.go 1.3 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
package balance

import (
	"encoding/json"
	entity "github.com/eolinker/goku/server/entity/balance-entity-service"
)

type Param struct {
	Name string `opt:"balanceName,require"`
	ServiceName string `opt:"serviceName,require"`
	AppName string `opt:"appName"`
	Static string `opt:"static"`
	StaticCluster string `opt:"staticCluster"`
	Desc string `opt:"balanceDesc"`
}


type Info struct {
	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"`
}

func ReadInfo(balance *entity.Balance) *Info {
	info:=&Info{
		Name:          balance.Name,
		ServiceName:   balance.ServiceName,
		ServiceType:   balance.ServiceType,
		ServiceDriver: balance.ServiceDriver,
		AppName:	   balance.AppName,
		Static:        balance.Static,
		StaticCluster: nil,
		Desc:          balance.Desc,
		CreateTime:    balance.CreateTime,
		UpdateTime:    balance.UpdateTime,
	}
	json.Unmarshal([]byte(balance.StaticCluster),&info.StaticCluster)
	return info
}