model/meta/MetaHostType.go
crusader e38f5b60a5 ing
2018-10-10 22:27:56 +09:00

56 lines
1.2 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
)
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],
}
}