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 MetaHostTypeEnumWLANAccessPoint MetaHostTypeEnumMediaServer ) var ( metaHostTypeEnumID = map[MetaHostTypeEnum]string{ MetaHostTypeEnumHost: "HOST", MetaHostTypeEnumNAS: "NAS", MetaHostTypeEnumPrinter: "PRINTER", MetaHostTypeEnumRouter: "ROUTER", MetaHostTypeEnumWLANAccessPoint: "WLAN_ACCESS_POINT", MetaHostTypeEnumMediaServer: "MEDIA_SERVER", } metaHostTypeEnumKey = map[string]MetaHostTypeEnum{ "HOST": MetaHostTypeEnumHost, "NAS": MetaHostTypeEnumNAS, "PRINTER": MetaHostTypeEnumPrinter, "ROUTER": MetaHostTypeEnumRouter, "WLAN_ACCESS_POINT": MetaHostTypeEnumWLANAccessPoint, "MEDIA_SERVER": MetaHostTypeEnumMediaServer, } ) 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], } }