model/meta/MetaHostType.go

54 lines
1.2 KiB
Go
Raw Normal View History

2018-09-12 03:10:59 +00:00
package meta
import (
"encoding/json"
"git.loafle.net/overflow/model/util"
)
type MetaHostType struct {
ID json.Number `json:"id,Number,omitempty"`
Name string `json:"name,omitempty"`
Key string `json:"key,omitempty"`
CreateDate *util.Timestamp `json:"createDate,omitempty"`
}
type MetaHostTypeEnum int
const (
MetaHostTypeEnumHost MetaHostTypeEnum = iota + 1
MetaHostTypeEnumNAS
MetaHostTypeEnumPrinter
MetaHostTypeEnumRouter
)
var (
metaHostTypeEnumID = map[MetaHostTypeEnum]string{
MetaHostTypeEnumHost: "HOST",
MetaHostTypeEnumNAS: "NAS",
MetaHostTypeEnumPrinter: "PRINTER",
MetaHostTypeEnumRouter: "ROUTER",
}
metaHostTypeEnumKey = map[string]MetaHostTypeEnum{
"HOST": MetaHostTypeEnumHost,
"NAS": MetaHostTypeEnumNAS,
"PRINTER": MetaHostTypeEnumPrinter,
"ROUTER": MetaHostTypeEnumRouter,
}
)
func (e MetaHostTypeEnum) String() string {
return metaHostTypeEnumID[e]
}
func ToMetaHostTypeEnum(v *MetaHostType) MetaHostTypeEnum {
return metaHostTypeEnumKey[v.Key]
}
func ToMetaHostType(v MetaHostTypeEnum) *MetaHostType {
return &MetaHostType{
Key: metaHostTypeEnumID[v],
}
}