model/meta/MetaHostType.go

63 lines
1.6 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
2018-10-10 13:27:56 +00:00
MetaHostTypeEnumWLANAccessPoint
MetaHostTypeEnumMediaServer
2018-10-12 17:26:06 +00:00
MetaHostTypeEnumMultiScreen
2018-09-12 03:10:59 +00:00
)
var (
metaHostTypeEnumID = map[MetaHostTypeEnum]string{
2018-10-10 13:31:48 +00:00
MetaHostTypeEnumHost: "HOST",
MetaHostTypeEnumNAS: "NAS",
MetaHostTypeEnumPrinter: "PRINTER",
MetaHostTypeEnumRouter: "ROUTER",
MetaHostTypeEnumWLANAccessPoint: "WLAN_ACCESS_POINT",
MetaHostTypeEnumMediaServer: "MEDIA_SERVER",
2018-10-12 17:26:06 +00:00
MetaHostTypeEnumMultiScreen: "MULTI_SCREEN",
2018-09-12 03:10:59 +00:00
}
metaHostTypeEnumKey = map[string]MetaHostTypeEnum{
2018-10-10 13:31:48 +00:00
"HOST": MetaHostTypeEnumHost,
"NAS": MetaHostTypeEnumNAS,
"PRINTER": MetaHostTypeEnumPrinter,
"ROUTER": MetaHostTypeEnumRouter,
"WLAN_ACCESS_POINT": MetaHostTypeEnumWLANAccessPoint,
"MEDIA_SERVER": MetaHostTypeEnumMediaServer,
2018-10-12 17:26:06 +00:00
"MULTI_SCREEN": MetaHostTypeEnumMultiScreen,
2018-09-12 03:10:59 +00:00
}
)
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],
}
}