model/meta/MetaHostType.go
crusader 1544a25336 ing
2018-10-13 02:26:06 +09:00

63 lines
1.6 KiB
Go

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